简体   繁体   English

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

[英]Unrecognized SSL message, plaintext connection? Exception

I have a java complied package to speak with the https server on net.我有一个 java 符合 package 与网络上的 https 服务器交谈。 Running the compilation gives the following exception:运行编译会出现以下异常:

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)

I think this is due to the connection established with the client machine is not secure.我认为这是由于与客户端计算机建立的连接不安全。 Is there any way to configure the local machine or ports in order to connect to the remote https server?有什么方法可以配置本地机器或端口以连接到远程 https 服务器?

I think this is due to the connection established with the client machine is not secure.我认为这是由于与客户端计算机建立的连接不安全。

It is due to the fact that you are talking to an HTTP server, not an HTTPS server.这是因为您正在与 HTTP 服务器交谈,而不是 HTTPS 服务器。 Probably you didn't use the correct port number for HTTPS.可能您没有为 HTTPS 使用正确的端口号。

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

You should have a local SMTP domain name that will contact the mail server and establishes a new connection as well you should change the SSL property in your programming below您应该有一个本地 SMTP 域名,它将联系邮件服务器并建立新连接,您应该在下面的编程中更改 SSL 属性

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection

 props.put("mail.smtp.socketFactory.fallback", "true"); // Should be true

I got the same error message when I forgot to log in to the company firewall, before performing a POST request through a proxy.在通过代理执行 POST 请求之前,当我忘记登录公司防火墙时,我收到了相同的错误消息。

I got the same error.我得到了同样的错误。 it was because I was accessing the https port using http.. The issue solved when I changed http to https.这是因为我正在使用 http 访问 https 端口。当我将 http 更改为 Z5E0656C500A1C87B4 时问题解决了。

Adding this as an answer as it might help someone later.添加此作为答案,因为它可能会在以后帮助某人。

I had to force jvm to use the IPv4 stack to resolve the error.我不得不强制 jvm 使用 IPv4 堆栈来解决错误。 My application used to work within company network, but while connecting from home it gave the same exception.我的应用程序曾经在公司网络中工作,但是在家中连接时出现了同样的异常。 No proxy involved.不涉及代理。 Added the jvm argument -Djava.net.preferIPv4Stack=true and all the https requests were behaving normally.添加了 jvm 参数-Djava.net.preferIPv4Stack=true并且所有https请求都正常运行。

I face the same issue from Java application built in Jdevelopr 11.1.1.7 IDE.我在 Jdevelopr 11.1.1.7 IDE 中内置的 Java 应用程序中遇到了同样的问题。 I solved the issue by unchecking the use of proxy form Project properties.我通过取消选中使用代理表单项目属性解决了这个问题。

You can find it in the following: Project Properties -> (from left panle )Run/Debug/Profile ->Click (edit) form the right panel -> Tool Setting from the left panel -> uncheck (Use Proxy) option.您可以在以下位置找到它:项目属性->(从左面板)运行/调试/配置文件->从右侧面板单击(编辑)->左侧面板中的工具设置->取消选中(使用代理)选项。

i solved my problem using port 25 and Following prop我使用端口 25 和以下道具解决了我的问题

mailSender.javaMailProperties.putAll([
                "mail.smtp.auth": "true",
                "mail.smtp.starttls.enable": "false",
                "mail.smtp.ssl.enable": "false",
                "mail.smtp.socketFactory.fallback": "true",
        ]);

If you are running local using spring i'd suggest use:如果您使用 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();
}

It works for me using unit test.它适用于我使用单元测试。

Hope it's help!希望有帮助!

As EJP said, it's a message shown because of a call to a non-https protocol.正如 EJP 所说,这是由于调用非 https 协议而显示的消息。 If you are sure it is HTTPS, check your bypass proxy settings, and in case add your webservice host url to the bypass proxy list如果您确定它是 HTTPS,请检查您的绕过代理设置,以防万一将您的 Web 服务主机 url 添加到绕过代理列表中

It worked for me now, I have change the setting of my google account as below:它现在对我有用,我已经更改了我的谷歌帐户的设置,如下所示:

        System.out.println("Start");
        final String username = "myemail@gmail.com";
        final String password = "************";

        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.port", "465");
        props.put("mail.transport.protocol", "smtp");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.starttls.enable", "true");
        props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

         Session session = Session.getInstance(props,
                  new javax.mail.Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(username, password);
                    }
                  });


        try {
            Transport transport=session.getTransport();
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("myemail@gmail.com"));//formBean.getString("fromEmail")
            message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("myemail@gmail.com"));
            message.setSubject("subject");//formBean.getString(
            message.setText("mailBody");
            transport.connect();
            transport.send(message, InternetAddress.parse("myemail@gmail.com"));//(message);

            System.out.println("Done");

        } catch (MessagingException e) {
            System.out.println("e="+e);
            e.printStackTrace();
            throw new RuntimeException(e);

        }

Though I have enabled SSL and TSL while running program in this link of same post.虽然我在同一篇文章的这个链接中运行程序时启用了 SSL 和 TSL。 I spend a lot of time but than I realized and found this link.我花了很多时间,但我意识到并找到了这个链接。 And done 2 following steps and setting control in google.并完成了 2 个以下步骤并在谷歌中设置控制。 :

  • Disable the 2-step verification (password and OTP)禁用两步验证(密码和一次性密码)

  • Enabling to allow to access less secure app( Allow less secure apps: ON. )启用允许访问不太安全的应用程序(允许不太安全的应用程序:开。

Now I am able to send mail using above program.现在我可以使用上面的程序发送邮件了。

if connection is FTPS test:如果连接是 FTPS 测试:

FTPSClient ftpClient = new FTPSClient(protocol, false); FTPSClient ftpClient = new FTPSClient(protocol, false);

protocol = TLS,SSL and false = isImplicit.协议 = TLS、SSL 和 false = isImplicit。

In case you are running如果你正在跑步

  • Cisco AnyConnect Secure Mobility Agent Cisco AnyConnect 安全移动代理
  • Cisco AnyConnect Web Security Agent Cisco AnyConnect Web 安全代理

try stopping the service(s).尝试停止服务。

Not sure why I got a down vote for this answer.不知道为什么我对这个答案投了反对票。 In our corporate network this IS the solution to the issue.在我们的企业网络中,这是解决问题的方法。

I got the same issue and it got resolved by setting "proxyUser" and "proxyPassword" in system properties.我遇到了同样的问题,通过在系统属性中设置“proxyUser”和“proxyPassword”得到了解决。

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

along with "proxyHost" and "proxyPort"连同“proxyHost”和“proxyPort”

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

Hope it will work.希望它会奏效。

I was facing this exception when using Gmail.我在使用 Gmail 时遇到了这个异常。

In order to use Gmail I had to turn ON "Allow less secure apps" .为了使用 Gmail 我不得不打开“允许不太安全的应用程序”

This Gmail setting can be found at https://www.google.com/settings/security/lesssecureapps after login the gmail account.登录 gmail 帐户后,可以在https://www.google.com/settings/security/lesssecureapps找到此 Gmail 设置。

I've got similar error using camel-mail component to send e-mails by gmail smtp.我使用骆驼邮件组件通过 gmail smtp 发送电子邮件时遇到了类似的错误。

The solution was changing from TLS port (587) to SSL port (465) as below:解决方案从 TLS 端口 (587) 更改为 SSL 端口 (465),如下所示:

<route id="sendMail">
  <from uri="jason:toEmail"/>
  <convertBodyTo type="java.lang.String"/>
  <setHeader headerName="Subject"><constant>Something</constant></setHeader>
  <to uri="smtps://smtp.gmail.com:465?username=myemail@gmail.com&amp;password=mypw&amp;to=someemail@gmail.com&amp;debugMode=true&amp;mail.smtp.starttls.enable=true"/>
</route>

In case you use Jetty version 9 or earlier you need to add it to jetty by如果您使用 Jetty 版本 9 或更早版本,您需要通过以下方式将其添加到 jetty

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

and according to this Jetty: How to use SSL in Jetty client side并根据这个码头:How to use SSL in Jetty client side

from Jetty version 10 it should work out of the box从 Jetty 版本 10 开始,它应该可以开箱即用

If you're running the Java process from the command line on Java 6 or earlier, adding this switch solved the issue above for me:如果您在 Java 6 或更早版本的命令行上运行 Java 进程,添加此开关为我解决了上述问题:

-Dhttps.protocols="TLSv1" -Dhttps.protocols="TLSv1"

HERE A VERY IMPORTANT ANSWER:这是一个非常重要的答案:

You just change your API URL String (in your method) from https to http.. This could also be the cause:您只需将您的 API URL 字符串(在您的方法中)从 https 更改为 Z80791B3AE7002FACB8888DZ 也可以是。

client.resource("http://192.168.0.100:8023/jaxrs/tester/tester");

instead of代替

client.resource("https://192.168.0.100:8023/jaxrs/tester/tester");

Maybe your default cerficate has expired.也许您的默认证书已过期。 to renew it through admin console go "Security >SSL certificate and key management > Key stores and certificates > NodeDefaultKeyStore > Personal certificates" select the "default" alias and click on "renew" after then restart WAS.通过管理控制台 go “安全 > SSL 证书和密钥管理 > 密钥库和证书 > NodeDefaultKeyStore > 个人证书” select “默认”别名并单击“更新”,然后重新启动 WAS。

Another reason is maybe "access denided", maybe you can't access to the URI and received blocking response page for internal network access.另一个原因可能是“拒绝访问”,也许您无法访问 URI 并收到阻止内部网络访问的响应页面。 If you are not sure your application zone need firewall rule, you try to connect from terminal,command line.如果您不确定您的应用程序区域是否需要防火墙规则,请尝试从终端、命令行连接。 For GNU/Linux or Unix, you can try run like this command and see result is coming from blocking rule or really remote address: echo | nc -v yazilimcity.net 443对于 GNU/Linux 或 Unix,您可以尝试像此命令一样运行并查看结果来自阻塞规则或真正的远程地址: echo | nc -v yazilimcity.net 443 echo | nc -v yazilimcity.net 443

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SSLException:无法识别的SSL消息,AXIS Java应用程序中的纯文本连接错误 - SSLException: Unrecognized SSL message, plaintext connection error in AXIS java application 随机出现的javax.net.ssl.SSLException:无法识别的SSL消息,明文连接? - Random occurence of javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? Jmeter 侦听器显示“javax.net.ssl.SSLException:无法识别的 SSL 消息,纯文本连接?” - Jmeter listener showing “ javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?” 无法发送邮件 - javax.net.ssl.SSLException:无法识别的 SSL 消息,纯文本连接? - Unable to Send Mail - javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? ftp4j:client.login返回无法识别的SSL消息,纯文本连接? - ftp4j: client.login returns Unrecognized SSL message, plaintext connection? 连接到POP3服务器会出现无法识别的SSL消息,纯文本连接问题 - Connecting to POP3 server gives Unrecognized SSL message, plaintext connection issue SSLException:无法识别的 SSL 消息,明文连接? 通过代理在 Camel 中发送 https POST 时出错 - SSLException: Unrecognized SSL message, plaintext connection? error while sending https POST in Camel via PROXY 获取源网页的源代码,javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? - get source web page's source code, javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? spotify/dockerfile-maven 插件:无法构建映像:javax.net.ssl.SSLException:无法识别的 SSL 消息,纯文本连接 - spotify/dockerfile-maven plugin: Could not build image: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection 我无法使用具有自定义SSLContext的Apache FTPSClient通过FTPS连接到FTP服务器-获取“无法识别的SSL消息,纯文本连接?” - I cannot connect to my FTP server by FTPS with Apache FTPSClient with custom SSLContext - getting “Unrecognized SSL message, plaintext connection?”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM