knute
Posts: 473
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

JavaMail issue on Pi0 and 1 with openjdk-11

Wed Jul 17, 2019 4:03 pm

I have found some sort of a problem with JavaMail and openjdk-11 on a Pi0 or 1. To run Java 11 on a Pi0 or 1 you have to include the -zero command line option since openjdk-11 java won't run on a Pi0 or 1. The fix is to install the package openjdk-11-jre-zero which will run on a Pi0 or 1.

But I'm having a problem getting the zero jre to run my JavaMail program. It runs fine on a Pi3 even with the -zero command line option but won't run on my Pi1. The error I'm getting is:

javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2131)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:728)
at javax.mail.Service.connect(Service.java:364)
at javax.mail.Service.connect(Service.java:222)
at javax.mail.Service.connect(Service.java:171)
at javax.mail.Transport.send0(Transport.java:230)
at javax.mail.Transport.send(Transport.java:100)
at com.knutejohnson.temphum.TempHumReport.<init>(TempHumReport.java:81)
at com.knutejohnson.temphum.TempHumReport.main(TempHumReport.java:94)
Caused by: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
at java.base/sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1321)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1160)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:602)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:529)
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2126)
... 8 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:167)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
... 13 more

I don't know for sure what is causing the problem just that it won't run on the Pi1. It's possible that the Pi1 is just too slow but you would think there would be some mention of a timeout somewhere if that were the case.

This code runs just fine if openjdk-8 is installed instead of 11.

Any ideas greatly appreciated.

Thanks

User avatar
clicky
Posts: 383
Joined: Thu Oct 25, 2012 7:34 am

Re: JavaMail issue on Pi0 and 1 with openjdk-11

Wed Jul 17, 2019 6:45 pm

To me it seems like JVM cannot offer appropriate ... well... Certificate? Does not support protocol? Something like that. Maybe OpenJDK11 has some restrictions over old protocols (do not support them any more) while your server does not implement anything newer... SHA-1 being disabled, maybe? Maybe this has something to do with it:

https://www.java.com/en/configure_crypto.html

Forgive me for being so vague and so far from the issue - but reading stack trace it seemed like one side (your code or server you wanted to connect) didn't want to proceed with SSL negotiation and just gave up and above might be the reason...

knute
Posts: 473
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: JavaMail issue on Pi0 and 1 with openjdk-11

Wed Jul 17, 2019 8:34 pm

clicky wrote:
Wed Jul 17, 2019 6:45 pm
To me it seems like JVM cannot offer appropriate ... well... Certificate? Does not support protocol? Something like that. Maybe OpenJDK11 has
That's kind of what I thought but I'm not so sure now. I looked at that link but didn't see anything that I thought was obvious.

I did however find a simple solution to getting Java 11 running on Pi0/1 and that is to use Azul's embedded java. It seems to work fine and uses mixed mode execution and so is faster than the Zero JRE. Find it here:

https://www.azul.com/downloads/zulu-embedded/

I think that is the best plan for the moment anyway.

Musketeer
Posts: 152
Joined: Fri Feb 12, 2016 1:23 pm
Location: CZ

Re: JavaMail issue on Pi0 and 1 with openjdk-11

Wed Jul 17, 2019 9:09 pm

IS there reason why they don't have 12 already? 13 will be in September...
Linux is like woman - both wants 180 % of your time...
You want speed Java 9.8x? Throw it out of some Window(s)!
My girlfriend is terribly unmature - she always sinks my boats in bathtub!

Return to “Java”