“SocketException:未实现的未连接套接字”使用自签名SSL证书 [英] "SocketException: Unconnected sockets not implemented" with self-signed SSL certificate

查看:88
本文介绍了“SocketException:未实现的未连接套接字”使用自签名SSL证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我已经问过jmeter用户邮件列表的相同问题,但我也想在这里尝试一下 - 所以至少我可以在找到后用答案更新它。)

(I've asked the same question of the jmeter-user mailing list, but I wanted to try here as well - so at the least I can update this with the answer once I find it).

我在使用 JMeter 测试Tomcat webapp时遇到问题使用自签名SSL证书。 JMeter抛出一个SocketException,消息未实现未连接的套接字根据JMeter的文档,该应用程序的设计和编写接受任何证书,自签名或CA签名或其他。

I'm having trouble using JMeter to test a Tomcat webapp using a self-signed SSL cert. JMeter throws a SocketException with message Unconnected sockets not implemented. According to JMeter's docs, the application is designed and written to accept any certificate, self-signed or CA signed or whatever.

有没有人遇到过这个特定的例外?

Has anyone run into this specific exception before?

我试图从服务器导出此证书并将其导入我的本地密钥库(使用 keytool -import -alias tomcat -file ),但结果是相同的。

I've attempted to export this certificate from the server and import it into my local keystore (with keytool -import -alias tomcat -file ), but the result is the same.

我也尝试将javax.net.debug = all设置为JVM arg( JSSE参考指南将此列为调试步骤);但是,我没有在任何地方看到任何调试输出 - 我是否应该在标准输出/错误以外的地方预期?

I've also tried setting javax.net.debug=all as a JVM arg (the JSSE reference guide lists this as a debugging step); however, I don't see any debugging output anywhere - should I expect this somewhere other than standard out/error?

推荐答案

javax.net.SocketFactory implementation将所有 createSocket()方法的参数定义为abstract 。但是有一个 createSocket()方法没有看起来像这样的参数:

Most javax.net.SocketFactory implementations define all createSocket() methods that have parameters as abstract. But have a createSocket() method without parameters that looks like this:

public Socket createSocket() throws IOException {
   throw new SocketException("Unconnected sockets not implemented");
}

所以我是你的抽象 javax的子类。 net.SocketFactory 你将强制用参数覆盖方法,但很容易错过覆盖没有参数的 createSocket()方法。因此,如果您的代码调用 createSocket(),则抛出异常。只需覆盖方法即可完成。 :)

So I'v you subclass the abstract javax.net.SocketFactory you will be force to override the methods with parameter, but it's easy to miss to override the createSocket() method without parameters. Thus the exception is thrown if your code calls createSocket(). Simply override the method and the be done. :)

这篇关于“SocketException:未实现的未连接套接字”使用自签名SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆