I am trying to send an email with javamail,
on my local computer when I run my class the mail is well send.
On the production computer I get an error :
Caused by: javax.mail.MessagingException: Could not convert socket to TLS (java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl))
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1230)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:378)
at javax.mail.Service.connect(Service.java:271)
at javax.mail.Service.connect(Service.java:91)
at javax.mail.Service.connect(Service.java:76)
at javax.mail.Transport.send(Transport.java:94)
... 8 more
Caused by: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:179)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:199)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:249)
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1226)
... 13 more
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at java.security.Provider$Service.newInstance(Provider.java:1245)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:220)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:147)
at javax.net.ssl.SSLContext.getInstance(SSLContext.java:125)
at javax.net.ssl.SSLContext.getDefault(SSLContext.java:68)
at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:102)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:247)
... 14 more
Caused by: java.io.IOException: Invalid keystore format
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:633)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
at java.security.KeyStore.load(KeyStore.java:1185)
at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.getDefaultKeyManager(DefaultSSLContextImpl.java:150)
at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.<init>(DefaultSSLContextImpl.java:40)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at java.security.Provider$Service.newInstance(Provider.java:1221)
... 20 more
in the security path there is these files :
68595 Mar 9 2009 cacerts
2221 Mar 9 2009 java.policy
9937 Mar 9 2009 java.security
132 Mar 9 2009 javaws.policy
2940 Mar 9 2009 _local_policy.jar
2481 Feb 28 12:54 local_policy.jar
2469 Mar 9 2009 _US_export_policy.jar
2465 Feb 28 12:54 US_export_policy.jar
no trusted.certs files.
the production use the jdk 1.6.0_13, is it possible that some file are too old ?
Anoter detail every thing was working well in production until last monday (7/30) nothing changed in the code, and now I am getting this error .
It is hard to figure out what is wrong because I don’t even know which file is problematic.
If you have any idea I take it !
thanks for help !
Finaly the problem was that a custom keyStore was defined by the admin :
-Djavax.net.ssl.keyStore=xxxxxxx.p12
And it was missing this :
-Djavax.net.ssl.keyStoreType=pkcs12