SSL,Restful calls , java

Posted on 2014-08-20
Last Modified: 2014-09-08
  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
Question by:SiemensSEN
    LVL 21

    Expert Comment

    You don't need to. The browser should handled the ssl encryption theough the http URL.
    LVL 30

    Expert Comment

    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.

    Author Comment

    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);

    Open in new window

    This is the error when I use Https:
    com.sun.jersey.api.client.ClientHandlerException: 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
    LVL 35

    Accepted Solution

    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.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This video teaches viewers about errors in exception handling.

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now