Certificate Validation in an HTTPS Connection

Share

By default, accessing an HTTPS URL using the URL class results in an exception if the server’s certificate chain cannot be validated has not previously been installed in the trust store.

Working with: Eclipse as platform, JAVA for the programming language

Purpose: certificate yourself to a webservice so that you can perform operations and access his methods. This tutorial will only step you through the steps of certificating.

Steps to follow:
1. have the necessary certificate
2. install the keytool plugin
3. Java code to use

  1. If you don’t already have the certificate and you need to export it, remember to select the “Base-64 encoded x.509” option on the export options.

  2. Install the “keytool” plugin in Eclipse. Use this: http://keytool.sourceforge.net/update/ This keytool stores a multitude of certificates. You can import a new certificate in his  “store”. After you install the keytool, restart Eclipe. After that you will see in the top Eclipse menu another option “Keytool”. Click it and choose “Open keystore”. A new window will pop up asking you some information that you need to complete.

Meaning(Figure 1):

    – Type: choose JKS

    – Filename: the path to the java cacerts file(C:\Program Files\Java\jre6\lib\security\cacerts)

    – Password: changeit(it by default)
    Figure 1:

    Open Keystore


    After this, a “store” of already imported certificates will be open, at your disposal 😀 , but for this operation all you want to do is import your certificate into it.

    To do that right click on the name of the store and choose: “Import certificate”, like in figure 2.

    Figure 2:


    Import Certificate

    After you click the “Import certificate” this window will pop out :


    Certificate

     

    Keystore: path to the cacerts(as above)

    Filename : actual path for the certificate you want to import.

    Alias: give it a name as an identifier: eg: Xcertificate

    Just click “Finish” button.

    3. Now I java code, before everything you need to “tell” the program about the certificate you imported with keytool. These are the 2 lines of code:

    System.setProperty(PropsUtil.keyCert, PropsUtil.valueCertPath);

    System.setProperty(PropsUtil.trustPassKey, PropsUtil.trustPassValue);

    Where:

    keyCert = “javax.net.ssl.trustStore”;
    valueCertPath = “C:/Program Files/Java/jre6/lib/security/cacerts”;
    trustPassKey = “javax.net.ssl.trustStorePassword”;
    trustPassValue = “changeit”;

    And that’s about it.

    Help from Ciprian’s Radu document “Working with iManagement from Eclipse”.


    Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.

1 thought on “Certificate Validation in an HTTPS Connection”

Comments are closed.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close