WebSphere +简单 HTTPS Post = SocketException
这是我能做的最基本的事情 - 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(比如我的是cacerts)
第三步:输入你的密码(你还记得你的密码吗)?
步骤 4:如果数据库类型不是 PKS12 继续
步骤 5:将您的证书文件另存为 pks12
步骤 6:停止 Websphere
步骤 7:将您的旧证书文件重命名为“cacerts.bak”之类的名称 将您的新 PKS12 证书文件重命名为默认
第8步:重启websphere,得到合法错误
第9步:盈利
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.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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要的是导致此异常(“内部”异常)的异常的信息和堆栈。 printStackTrace() 不会打印这些。
要么使用合适的日志框架(如 log4j 或 slf4j)来为您执行此操作,要么您可以手动执行此操作。
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.