In a J2EE application running on WAS 6.1.0.11 (last update), I want to make a SSL connexion on a https url connexion.
I used this code:
System.setProperty("javax.net.debug", "all");
String ksFile = "cert/keystore.p12";
String ksPwd = "*****";
String trustFile = "cert/cacerts.jks";
String trustPwd = "*******";
System.setProperty("javax.net.ssl.keyStore", ksFile);
System.setProperty("javax.net.ssl.keyStorePassword", ksPwd);
System.setProperty("javax.net.ssl.trustStore", trustFile);
System.setProperty("javax.net.ssl.trustStorePassword", trustPwd);
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hv);
URL url = new URL("https://ip/context");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
InputStream urlData = connection.getInputStream();
String page;
StringBuffer buffer = new StringBuffer();
while (true) {
int data = urlData.read();
if (data < 0)
break;
buffer.append((char) data);
}
page = buffer.toString();
System.out.println(page);
This code works fine with a Sun JDK for example but not with WebSphere 6.1 JDK. With that one, I have this exception:
setting up default SSLSocketFactory
use class specified by ssl.SocketFactory.provider: com.ibm.websphere.ssl.protocol.SSLSocketFactory
try to load via ThreadContext Class Loader
use dummy SSLSocketFactory due to java.lang.ClassNotFoundException: Cannot find the specified class java.security.PrivilegedActionException: java.lang.ClassNotFoundException: com.ibm.websphere.ssl.protocol.SSLSocketFactory
export control - checking the cipher suites
java.net.SocketException: Cannot find the specified class java.security.PrivilegedActionException: java.lang.ClassNotFoundException: com.ibm.websphere.ssl.protocol.SSLSocketFactory
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:8)
at com.ibm.net.ssl.www2.protocol.https.b.afterConnect(b.java:91)
at com.ibm.net.ssl.www2.protocol.https.c.connect(c.java:15)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:943)
at com.ibm.net.ssl.www2.protocol.https.a.getInputStream(a.java:83)
at be.speos.swing.webchecker.temputil.SSLApplication.process(SSLApplication.java:85)
at be.speos.swing.webchecker.temputil.SSLApplication.main(SSLApplication.java:147)
Anyone can help me?
Thanks in advance
I'm at an airport and don't have time to read your post closely, but I
suggest you look at this paper:
http://www.ibm.com/developerworks/websphere/techjournal/0502_benantar/0502_benantar.html
- it will likely answer all your questions. If not, post back.
thanks