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


当前回答

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

其他回答

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

如果您正在使用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();
}

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

希望对大家有帮助!

我得到了同样的错误。这是因为我正在访问https端口使用http..当我将http更改为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);

希望它能起作用。

添加这个作为答案,因为它可能会帮助到其他人。

我不得不强制jvm使用IPv4堆栈来解决错误。我的应用程序过去在公司网络内工作,但从家里连接时,它给出了同样的异常。不涉及代理。增加了jvm参数 -Djava.net.preferIPv4Stack=true,所有https请求行为正常。