WebSphere + Simple HTTPS Post = SocketException

时间:2011-08-26 14:08:43

标签: java http ssl websphere

这与我可以做到的基本相同 - RAD全新设置,全新项目,所有默认设置和此代码:

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

    }

这是我得到的错误(不是非常有用的信息)

    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.HttpClient.executeMethod(HttpClient.java:497)

关于我可以尝试获得更具描述性错误的任何想法?

更新

当我查看“runtimes \ base_v61 \ profiles \ AppSrv01 \ logs \ ffdc”时,我发现此错误被打印到日志中:

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)

更新 - 回答 固定,这是一个有趣的问题,这是你如何解决它(如果你遇到它)

步骤1:在\ SDP70 \ jdk \ jre \ bin

中启动ikeyman.exe

步骤2:在SDP70 \ runtimes \ base_v61 \ java \ jre \ lib \ security中打开certs文件(例如,我的是cacerts)

第3步:输入您的密码(你还记得你的密码)吗?

步骤4:如果数据库类型不是PKS12继续

步骤5:将您的证书文件另存为pks12

第6步:停止Websphere

步骤7:将旧的证书文件重命名为“cacerts.bak”,将新的PKS12证书文件重命名为默认值

步骤8:重启websphere,获取合法错误

第9步:获利

1 个答案:

答案 0 :(得分:0)

您想要的是导致此异常的异常的信息和堆栈(“内部”异常)。 printStackTrace()不会打印出来。

使用适当的日志框架(如log4j或slf4j)为您执行此操作,或者您可以手动执行此操作。

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