未识别的SSL消息,明文连接?异常

时间:2021-08-01 19:38:01

I have a java complied package to speak with the https server on net. Running the compilation gives the following exception:

我有一个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)

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服务器?

16 个解决方案

#1


137  

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. Probably you didn't use the correct port number for HTTPS.

这是因为您正在与一个HTTP服务器对话,而不是一个HTTPS服务器。可能您没有为HTTPS使用正确的端口号。

#2


13  

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

#3


7  

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请求之前,当我忘记登录到公司防火墙时,我得到了同样的错误消息。

#4


2  

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改为https时,这个问题就解决了。

#5


1  

I face the same issue from Java application built in Jdevelopr 11.1.1.7 IDE. I solved the issue by unchecking the use of proxy form Project properties.

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

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.

您可以在下面找到它:项目属性—>(从左窗格)运行/调试/配置文件—>单击(编辑),形成右面板—来自左面板的>工具设置—> uncheck(使用代理)选项。

#6


1  

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. 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使用IPv4堆栈来解决错误。我的应用程序以前在公司的网络中工作,但是当从家里连接时,它给出了同样的例外。涉及任何代理。添加jvm参数-Djava.net.preferIPv4Stack=true,所有的https请求都正常运行。

#7


1  

if connection is FTPS test:

如果连接是FTPS测试:

FTPSClient ftpClient = new FTPSClient(protocol, false);

FTPSClient =新FTPSClient(协议,false);

protocol = TLS,SSL and false = isImplicit.

协议= TLS,SSL和false = isimplex。

#8


0  

As EJP said, it's a message shown because of a call to a non-https protocol. 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

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

#9


0  

In case you are running

如果你在跑步

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

try stopping the service(s).

试着停止服务(s)。

#10


0  

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.

希望它能工作。

#11


0  

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设置可以在登录Gmail帐户后在https://www.google.com/settings/security/lesssecureapps找到。

#12


0  

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",
        ]);

#13


-1  

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. I spend a lot of time but than I realized and found this link. And done 2 following steps and setting control in google. :

虽然我在同一篇文章的链接中启用了SSL和TSL。我花了很多时间,但我并没有意识到这一点。并在谷歌中进行2步设置控制。:

  • Disable the 2-step verification (password and OTP)

    禁用2步验证(密码和OTP)

  • Enabling to allow to access less secure app(Allow less secure apps: ON.)

    允许访问不安全的应用程序(允许不安全的应用程序:ON)。

Now I am able to send mail using above program.

现在我可以使用上面的程序发送邮件了。

#14


-1  

Another reason is maybe "access denided", maybe you can't access to the URI and received blocking response page for internal network access. 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

另一个原因可能是“拒绝访问”,可能您无法访问URI并接收到用于内部网络访问的阻塞响应页面。如果您不确定您的应用程序区域需要防火墙规则,您可以尝试从终端、命令行连接。对于GNU/Linux或Unix,您可以尝试像这样运行,并看到结果来自于阻塞规则或真正的远程地址:echo | nc -v yazilimcity.net 443

#15


-3  

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.

也许你的默认证书已经过期了。通过管理控制台进行更新,“安全>SSL证书和密钥管理>密钥存储库和证书> NodeDefaultKeyStore >个人证书”选择“默认”别名,然后在重启后点击“更新”。

#16


-3  

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 "

#1


137  

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. Probably you didn't use the correct port number for HTTPS.

这是因为您正在与一个HTTP服务器对话,而不是一个HTTPS服务器。可能您没有为HTTPS使用正确的端口号。

#2


13  

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

#3


7  

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请求之前,当我忘记登录到公司防火墙时,我得到了同样的错误消息。

#4


2  

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改为https时,这个问题就解决了。

#5


1  

I face the same issue from Java application built in Jdevelopr 11.1.1.7 IDE. I solved the issue by unchecking the use of proxy form Project properties.

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

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.

您可以在下面找到它:项目属性—>(从左窗格)运行/调试/配置文件—>单击(编辑),形成右面板—来自左面板的>工具设置—> uncheck(使用代理)选项。

#6


1  

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. 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使用IPv4堆栈来解决错误。我的应用程序以前在公司的网络中工作,但是当从家里连接时,它给出了同样的例外。涉及任何代理。添加jvm参数-Djava.net.preferIPv4Stack=true,所有的https请求都正常运行。

#7


1  

if connection is FTPS test:

如果连接是FTPS测试:

FTPSClient ftpClient = new FTPSClient(protocol, false);

FTPSClient =新FTPSClient(协议,false);

protocol = TLS,SSL and false = isImplicit.

协议= TLS,SSL和false = isimplex。

#8


0  

As EJP said, it's a message shown because of a call to a non-https protocol. 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

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

#9


0  

In case you are running

如果你在跑步

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

try stopping the service(s).

试着停止服务(s)。

#10


0  

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.

希望它能工作。

#11


0  

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设置可以在登录Gmail帐户后在https://www.google.com/settings/security/lesssecureapps找到。

#12


0  

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",
        ]);

#13


-1  

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. I spend a lot of time but than I realized and found this link. And done 2 following steps and setting control in google. :

虽然我在同一篇文章的链接中启用了SSL和TSL。我花了很多时间,但我并没有意识到这一点。并在谷歌中进行2步设置控制。:

  • Disable the 2-step verification (password and OTP)

    禁用2步验证(密码和OTP)

  • Enabling to allow to access less secure app(Allow less secure apps: ON.)

    允许访问不安全的应用程序(允许不安全的应用程序:ON)。

Now I am able to send mail using above program.

现在我可以使用上面的程序发送邮件了。

#14


-1  

Another reason is maybe "access denided", maybe you can't access to the URI and received blocking response page for internal network access. 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

另一个原因可能是“拒绝访问”,可能您无法访问URI并接收到用于内部网络访问的阻塞响应页面。如果您不确定您的应用程序区域需要防火墙规则,您可以尝试从终端、命令行连接。对于GNU/Linux或Unix,您可以尝试像这样运行,并看到结果来自于阻塞规则或真正的远程地址:echo | nc -v yazilimcity.net 443

#15


-3  

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.

也许你的默认证书已经过期了。通过管理控制台进行更新,“安全>SSL证书和密钥管理>密钥存储库和证书> NodeDefaultKeyStore >个人证书”选择“默认”别名,然后在重启后点击“更新”。

#16


-3  

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 "