0
votes

I am getting a javax.net.ssl.SSLHandshakeException when using the DocuSign API handshake.

Trying to use the DocuSign API login samples gives a cert error.

The following code is a sample from DocuSign. It sets up a Signer and DocuSign Configuration object. When doing the setDefaultApiClient call, the error is generated.

Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: jav ax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKI X path building failed: sun.security.provider.certpath.SunCertPathBuilderExcepti on: unable to find valid certification path to requested target at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle (URLConnectionClientHandler.java:155) at com.sun.jersey.api.client.Client.handle(Client.java:652) at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682) at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74) at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509) at com.docusign.esign.client.ApiClient.getAPIResponse(ApiClient.java:563) at com.docusign.esign.client.ApiClient.invokeAPI(ApiClient.java:595) at com.docusign.esign.api.AuthenticationApi.login(AuthenticationApi.java:156)

Added

// initialize the api client ApiClient apiClient = new ApiClient();  
apiClient.setBasePath(BaseUrl); // create JSON formatted auth header   
String creds = "{\"Username\":\"" + UserName + 
   "\",\"Password\":\"" + Password + "\",\"IntegratorKey\":\"" +
   IntegratorKey + "\"}"; 
apiClient.addDefaultHeader("X-DocuSign-Authentication", creds);
System.out.println("assign api client to the Configuration object ");
Configuration.setDefaultApiClient(apiClient); } 
1
Here is the code used to implement the docusign api call - Tom Larson
// initialize the api client ApiClient apiClient = new ApiClient(); apiClient.setBasePath(BaseUrl); // create JSON formatted auth header String creds = "{\"Username\":\"" + UserName + "\",\"Password\":\"" + Password + "\",\"IntegratorKey\":\"" + IntegratorKey + "\"}"; apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); System.out.println("assign api client to the Configuration object "); Configuration.setDefaultApiClient(apiClient); } - Tom Larson
Welcome to StackOverflow! Just as a tip, you can edit your question so that all of your code is in the question. - Daniel M.
Welcome to StackOverflow! I copied your comment into your question. - Larry K
Please remember to upvote all useful answers (including those to others' questions), and to "check" the answer that best solves your question. - Larry K

1 Answers

0
votes

"unable to find valid certification path" means that you need to set up your Java stack with the "standard" set of trusted root certs.

What's happening: you're trying to make an SSL connection to DocuSign. As part of the SSL process, your machine has to determine if it trusts the far end (DocuSign in this case) or not.

To do so: your SSL stack tries to build a trust path from its trust store of root CA certs to the cert offered by DocuSign. But it can't since you haven't set up your trust store properly.

The usual "standard" set of trusted root certs are the ones that the Mozilla Firefox browser uses.

See https://curl.haxx.se/docs/caextract.html

How to load them into your Java stack as trusted certs is stack-dependent.

This SO question looks relevant but I'm not a Java guy. Ask another question if you can't figure it out.