'Facing SSL issue suddenly while calling razorpay api

I am working on a Razorpay payment gateway integration My API was working fine but suddenly I am started getting the error Unable to get local issuer certificate This error can be resolved in postman by disabling SSL certificate verification. But I can't able to figure out the original solution for this error. Also this error appears on my Java application while using razorpay-api on the below code.

orderResponse = razorpay.Orders.create(orderRequest);
jsonNode = RazorpayUtils.mapper.readTree(orderResponse.toString());
            if (jsonNode.get("status").textValue().equals("created")) {
                System.out.println("Response of order api");
                response.setRazorpayOrderID(jsonNode.get("id").textValue());
                response.setRazorpayOrderAmount(jsonNode.get("amount").asInt());
                response.setOrderRecieptID(jsonNode.get("receipt").textValue());
                response.setRazorpayOrderStatus(jsonNode.get("status").textValue());
                response.setRazorpayCurrencyCode(jsonNode.get("currency").textValue());
                System.out.println("Response of Razorpay Order API." + response);
                return response;
            }

and facing below error.

com.razorpay.RazorpayException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.razorpay.ApiUtils.processRequest(ApiUtils.java:145)
    at com.razorpay.ApiUtils.postRequest(ApiUtils.java:62)
    at com.razorpay.ApiClient.post(ApiClient.java:40)
    at com.razorpay.OrderClient.create(OrderClient.java:14)
    at com.razorpayImp.services.OrderServiceImpl.createOrder(OrderServiceImpl.java:44)
    at com.razorpayImp.controllers.OrderController.createOrder(OrderController.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)

So how to get this local issuer certificate to resolve this SSL certificate issue?

Note: I got this issue for the past 2 days previously the same code was working fine.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source