打开连接失败:javax.net.ssl.SSLException:无法识别的SSL消息,明文连接?

SUN*_*NNY 3 java ssl

我使用SOAP UI创建了一个休息模拟服务.我正在尝试从我的java类连接它.但它失败了,错误

Open connection failed: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
sun.security.ssl.InputRecord.handleUnknownRecord(Unknown Source)
sun.security.ssl.InputRecord.read(Unknown Source)
sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
Run Code Online (Sandbox Code Playgroud)

我不确定我哪里出错了.

以下是代码 -

java.net.URL url = new URL(null, address,new sun.net.www.protocol.https.Handler());
connection = (javax.net.ssl.HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestMethod("GET");
connection.connect();
Run Code Online (Sandbox Code Playgroud)

我想连接的URL是 - http:// localhost:8089

Sky*_*ker 9

如果你想使用HTTPS那么

https(http over SSL)协议处理程序有自己的一组属性:

https.proxyHost
https.proxyPort
Run Code Online (Sandbox Code Playgroud)

正如你可能猜到这些工作方式与它们的http对应方式完全相同,所以我们不会详细介绍,除非提到默认端口号,这次是443,而对于"非代理主机"列表, HTTPS协议处理程序将使用与http处理程序相同的内容(即http.nonProxyHosts).

资源链接:

Java网络和HTTPS代理

方案1:

将以下内容添加到JAVA_OPTS环境变量中:

-Djsse.enableSNIExtension=false
Run Code Online (Sandbox Code Playgroud)

重新启动 Crowd实例.

资源链接:

https://confluence.atlassian.com/crowdkb/unrecognized-ssl-message-plaintext-connection-582877397.html

方案2:

我认为这是由于与客户端机器建立的连接不安全.这是因为您正在与HTTP服务器通信,而不是HTTPS服务器.可能您没有为HTTPS使用正确的端口号.

归功于 @ EJP

资源链接:

无法识别的SSL消息,明文连接?例外

解决方案3:

如果您使用SMTP域名,则mail.smtp.socketFactory.fallback必须为true.

props.put("mail.smtp.socketFactory.fallback", "true"); // Make it true
Run Code Online (Sandbox Code Playgroud)

你也可以通过这个链接:javax.net.ssl.SSLException:无法识别的SSL消息,明文连接?


归档时间:

查看次数:

29382 次

最近记录:

6 年,6 月 前