Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3273

EJB with https connection to Patch Service using TrustCAs

$
0
0

Hello Everybody,

 

We are currently facing the following issue. We developed an EJB in order to call a patch method of a Rest Service. It is working fine for http, but with https we are having some problems

 

This is our code with the org.apache.http.client.HttpClient class:

 

     final HttpClient httpClient = new DefaultHttpClient();


     // Url

     HttpPatch httpPatch = new HttpPatch(serviceURL);


     // Headers

     httpPatch.addHeader("Accept", "*/*");

     httpPatch.addHeader("Content-Type", "application/json");

     String userCredentials = serviceUser + ":" + servicePassw;

     String basicAuth = "Basic " + new String(new Base64().encode(userCredentials.getBytes()));

     httpPatch.addHeader("Authorization", basicAuth);

 

     StringEntity entity = new StringEntity(patchString, "UTF-8");

     entity.setContentType("application/json");

     httpPatch.setEntity(entity);

 

     // Response

     HttpResponse response;

     response = httpClient.execute(httpPatch);

 

Apparently it does not use the certificates and keys from the NWA TrustedCAs Keystore of the AS Java. So we did a workaround and put the certificate in the Java Trust Store as explained in the following post (J2EE Client application using SSL, keystore question.). This worked fine, however our client is not completely satisfied as he wants to use the NWA TrustedCAs Keystore and not the Java Keystore of the JVM. I have read that apparently I can say which Keystore it should use, but it is not clear to me how to do it with the httpClient.

 

Has anyone faced a similar issue?

 

Thank you!


Viewing all articles
Browse latest Browse all 3273

Trending Articles