我有一个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服务器?


当前回答

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

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

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

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

其他回答

如果连接是FTPS test:

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

protocol = TLS,SSL and false = isImplicit。

如果你在Java 6或更早的版本上从命令行运行Java进程,添加这个开关为我解决了上面的问题:

-Dhttps.protocols=“TLSv1”

如果您正在使用spring运行本地,我建议使用:

@Bean
public AmazonDynamoDB amazonDynamoDB() throws IOException {
    return AmazonDynamoDBClientBuilder.standard()
            .withCredentials(
                    new AWSStaticCredentialsProvider(
                            new BasicAWSCredentials("fake", "credencial")
                    )
            )
            .withClientConfiguration(new ClientConfigurationFactory().getConfig().withProtocol(Protocol.HTTP))
            .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration("localhost:8443", "central"))
            .build();
}

它适用于我使用单元测试。

希望对大家有帮助!

正如EJP所说,这是由于调用非https协议而显示的消息。 如果你确定它是HTTPS,检查你的旁路代理设置,并在这种情况下将你的webservice主机url添加到旁路代理列表

以防你在跑步

思科AnyConnect安全移动代理 思科AnyConnect Web安全代理

尝试停止服务。

在我们的公司网络中,这是解决问题的方法。