Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SSL,Restful calls , java

Posted on 2014-08-20
5
Medium Priority
?
435 Views
Last Modified: 2014-09-08
Hello,
  I have application that currently exposes some restful API's . I am able to access and retrieve information  via http using jersey.  Now , I enable HTTS  for the application by using the keytool command to generate the .jks and .csr file. . The application now run via HTTPS

What do I need to do on the client to make the rest call work using https ?. Do I have to import the certificate into my client keystore?

Thanks for your help
0
Comment
Question by:SiemensSEN
4 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 40276127
You don't need to. The browser should handled the ssl encryption theough the http URL.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 40276611
If your client is a Java program, it needs to use HttpsUrlConnection instead of HttpUrlConnection. In any case, the former is a sub-class of the latter.
0
 

Author Comment

by:SiemensSEN
ID: 40276972
I am using Jersey to call the restAPI

String auth= new String(Base64.encode(JConstant.ID_PASS));
Client client = Client.create();
webResource = client.resource(JConstant.ROOTURL+"/issue/"+issueID);
response = webResource.header("Authorization", "Basic " + auth).type("application/json").accept("application/json").get(ClientResponse.class);
return(response.getEntity(String.class));

Open in new window


This is the error when I use Https:
com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present


I copied the .cer file and import it in my java cacaerts but it did not help

Thanks for your help
0
 
LVL 36

Accepted Solution

by:
mccarl earned 2000 total points
ID: 40278263
What do I need to do on the client to make the rest call work using https ?. Do I have to import the certificate into my client keystore?
As detailed in your other question, yes, importing the certificate is probably the best answer.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question