我有一个java编译包与https服务器在网上说话。运行编译会出现以下异常:

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
    at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)

我认为这是因为与客户端机器建立的连接不安全。是否有任何方法配置本地机器或端口以连接到远程https服务器?


当前回答

我也遇到了同样的问题,通过在系统属性中设置“proxyUser”和“proxyPassword”来解决。

System.setProperty("http.proxyUser", PROXY_USER);
System.setProperty("http.proxyPassword", PROXY_PASSWORD);

连同“proxyHost”和“proxyPort”

System.setProperty("http.proxyHost", PROXY_ADDRESS);
System.setProperty("http.proxyPort", PROXY_PORT);

希望它能起作用。

其他回答

我得到了同样的错误。这是因为我正在访问https端口使用http..当我将http更改为https时,问题解决了。

当我在通过代理执行POST请求之前忘记登录公司防火墙时,我得到了同样的错误消息。

如果连接是FTPS test:

FTPSClient ftpClient =新的FTPSClient(协议,false);

protocol = TLS,SSL and false = isImplicit。

我在Jdevelopr 11.1.1.7 IDE中构建的Java应用程序也面临同样的问题。我通过取消对代理表单项目属性的使用来解决这个问题。

你可以在下面找到它: 项目属性->(从左边面板)运行/调试/配置文件->在右边面板单击(编辑)->工具设置从左边面板->取消(使用代理)选项。

如果您使用的是Jetty版本9或更早的版本,则需要将其添加到Jetty 通过

RUN java -jar ${JETTY_HOME}/start.jar --add-to-startd=https

根据这个 Jetty:如何在Jetty客户端使用SSL

从Jetty版本10,它应该工作出来的盒子