开发者

WebSphere + Simple HTTPS Post = SocketException

This is about as basic as I can make it - brand new setup in RAD, brand new project, all default settings and this code:

        try {
        String url = "https://www.verisign.com";
        HttpClient client = new HttpClient();
        PostMethod post = new PostMethod(url);
        client.executeMethod(post);
        String response2 = post.getResponseBodyAsString();

    } catch (Exception e) {
        e.printStackTrace();

    }

This is the error I get (not very informative imho)

    java.net.SocketException
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:5)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:93)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:651)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:628)
at org.apache.commons.httpclient.开发者_StackOverflow中文版HttpClient.executeMethod(HttpClient.java:497)

Any ideas on what I could try to get a more descriptive error?

UPDATE

When I look in "runtimes\base_v61\profiles\AppSrv01\logs\ffdc" I find this error getting printed to the logs:

com.ibm.websphere.ssl.SSLException: java.io.IOException: DerInputStream.getLength(): lengthTag=127, too big.
at com.ibm.websphere.ssl.JSSEHelper.getSSLSocketFactory(JSSEHelper.java:583)
at com.ibm.websphere.ssl.protocol.SSLSocketFactory.<init>(SSLSocketFactory.java:87)
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1243)
at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:9)
at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:93)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:651)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:628)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:497)

UPDATE - With the answer FIXED, that was a fun issue, here's how you resolve it (if you ever come across it)

Step 1: Launch ikeyman.exe in \SDP70\jdk\jre\bin

Step 2: Open your certs file in SDP70\runtimes\base_v61\java\jre\lib\security (for example, mine is cacerts)

Step 3: Enter in your password (do you remember your password)?

Step 4: IF THE DATABASE TYPE IS NOT PKS12 CONTINUE

Step 5: Save your cert file as pks12

Step 6: Stop Websphere

Step 7: Rename your old cert file to something like "cacerts.bak" rename your new PKS12 certs file to be the default

Step 8: Restart websphere, get legitimate error

Step 9: Profit


What you want is the information and stack of the exceptions that caused this exception (the "inner" exceptions). printStackTrace() will not print these out.

Either use a proper logging framework (like log4j or slf4j) that does this for you, or you can do it manually.

e.printStackTrace();
Throwable cause = e.getCause();
while (cause != null) {
    cause.printStackTrace();
    cause = cause.getCause();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜