Re: Error when I try to pass JKS file

Solved! Go to solution
vascubrian
Dabbler

Error when I try to pass JKS file

Tests in error:

  postmerchantPushPaymentsPostTest(com.visa.developer.sample.mvisa_api.api.MvisaApiTest): I/O error on POST request for "https://sandbox.api.visa.com/visadirect/mvisa/v1/merchantpushpayments": PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

1 REPLY 1
API_Managers
Visa Developer Support Specialist

Re: Error when I try to pass JKS file

Hey @vascubrian,

 

I'm happy to help. Please review the below sample code, try it and make changes. Then try to conduct the test again and share your results with us.


 
1. No need to set any password for private key. Please comment that line.
//apiClient.setPrivateKeyPassword("******");
 
2. Kindly comment the below highlighted line in ApiClient.java.
 
protected RestTemplate getRestTemplateForMutualAuth() {
        try {
            KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
            FileInputStream keystoreInputStream = new FileInputStream(keystorePath);
            keystore.load(keystoreInputStream, keystorePassword.toCharArray());
            keystoreInputStream.close();
 
            SSLContext sslcontext = SSLContexts.custom().useProtocol("TLS")
                    .loadKeyMaterial(keystore, keystorePassword.toCharArray())
                    //.loadTrustMaterial(new File(keystorePath), keystorePassword.toCharArray())
                    .build();

 




Thanks,

Tee



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.