Unrecognized SSL message, plaintext connection? Exception
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.
Unable to Send Mail - javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
<prop key="mail.smtp.ssl.enable">true</prop>
You want either mail.smtp.ssl.enable
for implicit SSL directly after TCP connect (port 465) or mail.smtp.starttls.enable
for explicit SSL using the STARTTLS command (port 25). But with your current properties you set both to true.
This means it will do a TCP connect to port 25 and try a SSL handshake there. This will fail because the server is sending a plain text greeting from the SMTP dialog and not the expected SSL handshake. Thus you get
Unrecognized SSL message, plaintext connection?
To fix it make sure that you either use implicit or explicit SSL but not both depending on the port, i.e. for port 25 mail.smtp.ssl.enable
should be false.
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection. when routing with Eureka client discovery, after deploy on tomcat server
Finally I found the solution. by adding property
ribbon.eureka.enabled=false in zuul every thing is working fine.
SSLException:Unrecognized SSL message, plaintext connection
I found the answer. so when i configured spray to HTTPS
it cant accept the HTTP
requests it accepts only HTTPS
requests.
Unsupported or unrecognized ssl-message exception at startHandshake after issuing STARTTLS command in a java program
To be clear, the main intention behind this answer is to mark the question as answered, because actually the solution is found in the comments to the question. The problem lies in the readInputRun() that reads part of the ServerHello, so letting the reading thread interrupt itself before the handshake and restarting it after it solves it:
dos.write("STARTTLS\r\n".getBytes());
SSLSocket sslSocket = (SSLSocket) ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket(socket, "mail.arcor.de", 587, true);
dos = new DataOutputStream(sslSocket.getOutputStream());
dis = new DataInputStream(sslSocket.getInputStream());
sslSocket.startHandshake();
new Thread(() -> {readInputRun();}).start();
dos.write(("EHLO " + InetAddress.getLocalHost().getHostAddress() + "\r\n").getBytes());
dos.write("QUIT\r\n".getBytes());
and:
private static void readInputRun() {
try {
int input;
String allInput = "";
while((input = dis.read()) >= 0) {
allInput += (char) input;
System.out.print(allInput.charAt(allInput.length() - 1));
if(allInput.endsWith("Start TLS\r\n")) {
break;
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
Related Topics
Conditionally Ignoring Tests in Junit 4
What Is the "Continue" Keyword and How Does It Work in Java
Java 8: Difference Between Two Localdatetime in Multiple Units
Using Regular Expressions to Extract a Value in Java
How to Set the Default Locale in the Jvm
Cut Out Image in Shape of Text
Scale the Imageicon Automatically to Label Size
Update Jlabel Every X Seconds from Arraylist<List> - Java
Differences Between Oracle Jdk and Openjdk
What Is This: [Ljava.Lang.Object;
Getting the 'External' Ip Address in Java
Dynamic Spring Data JPA Repository Query with Arbitrary and Clauses
Jrbeancollectiondatasource: How to Show Data from the Java.Util.List from Javabean
In What Order Do Static/Instance Initializer Blocks in Java Run