Use the HTTPS protocolTag(s): Networking


For Applets, both IE and NN have implemented https in their java.net.URL class so just use it exactly as you would for a regular http URL.
URL ssl = new URL("https://www.secureserver.com);
InputStream is = ssl.openStream();

For application, take a look at the Sun's Secure Socket Extension (JSSE).

Before connecting with a secure URL, we must do this first :

java.security.Security.addProvider(new
   com.sun.net.ssl.internal.ssl.Provider());

System.setProperty
   ("java.protocol.handler.pkgs",
    "com.sun.net.ssl.internal.www.protocol");
A useful link for that is this JavaWorld's Tip

Since JDK 1.4, the JSSE package is included so you don't have to add anything special. However you may need to import the certificate from the host (that is the server that you are connecting to using the https: protocol). One easy way to do this is to open a secured page (say https://mysecuredhost.com) with IE, click on the SSL-symbol (bottom right) and exported the key into the file "c:\cacerts.ce". Go in "%java_home%\bin" and type this:

keytool -import -v -alias meincert -trustcacerts -file c:\

blog comments powered by Disqus