• Register
0 votes
446 views

Problem :

I have a java complied package and it is sopposed to communicate with https server on net. But when i try running the compilation gives the following exception:

javax.net.ssl.sslexception: unrecognized ssl message, plaintext connection?

6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had the similar issue but its working for me now, I have changed the setting of my google account by running bellow code: 

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); 

}

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

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

Now you will be able to send mail using above program.

Further Readings:

https://github.com/nctoolbox/nctoolbox/issues/94

9 7 4
38,600 points

Related questions

0 votes
1 answer 2 views
2 views
Problem: Hello. I'm getting: javax.net.ssl.SSLException: Received fatal alert: bad_record_mac I will check it out (i think ive already deal with this error in the past), just please give me few days, have some offline things to do Also, would you be so ... is working with both HttpBrowser and HttpRequest, on JDK 1.7.0_45? The workaround should be: socket.setEnabledProtocols(new String[]{"SSLv3"});
asked 12 hours ago Ali 4.3k points
0 votes
1 answer 407 views
407 views
Problem : I am trying to call an SSL protected web service running on JDK7 based client, but getting bellow error javax.net.ssl.sslexception received fatal alert unexpected_message
asked Nov 5, 2019 peterlaw 6.9k points
0 votes
2 answers 404 views
404 views
Problem : Has anyone faced this error before? I am new to SSL javax.net.ssl.sslexception: received fatal alert: protocol_version
asked Nov 2, 2019 peterlaw 6.9k points
0 votes
2 answers 8 views
8 views
Problem: I am getting javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake exception when I try to do HTTPS Post of a web service through internet. But same code works for other internet hosted web services. I tried many things, nothing is helping me. I posted my sample code here. Can anyone please help me to resolve this problem?
asked Feb 2 Ali 4.3k points
0 votes
3 answers 249 views
249 views
Problem : I am trying to setup a SSL Socket connection. But i am getting below error javax.net.ssl.sslhandshakeexception received fatal alert bad_certificate
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 89 views
89 views
Problem: I am trying to consume a PHP webservice which has the SSL certificate. I have the .net 3.5 Class library it references the webservice with a 'Add Service references' in Visualstudio 2010 If I try calling the main method of my webservice then I ... SslPolicyErrors sslPolicyErrors) { return true; } But somehow it is not working. Also I have already a certificate installed on my own pc.
asked Aug 12, 2020 Raphael Pacheco 4.9k points
0 votes
2 answers 1.3K views
1.3K views
Problem: I am attempting to download records from a https webpage and continue getting the accompanying error: OpenSSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure Unable to establish SSL connection. From perusing sites online I assemble I need to give ... alternative however that didn't work. wget version: wget-1.13.4 openssl version: OpenSSL 1.0.1f 6 Jan 2014
asked Nov 30, 2019 alecxe 7.5k points
0 votes
1 answer 55 views
55 views
Problem : I have the Java web service client, which consumes the web service via HTTPS. When I try to connect to the service URL (https://AAA.BBB.CCC.DDD:9443/ISomeService ), I get the exception as below: “ Java.security.cert.CertificateException: No subject alternative names present.”
asked Jan 21, 2020 jwilliam 3.9k points
0 votes
1 answer 146 views
146 views
Problem : I have a Java web service client, which consumes a web service via HTTPS. When I connect to the service URL, I get the exception java.security.cert.CertificateException: No subject alternative names present.
asked Oct 22, 2019 peterlaw 6.9k points