Ans:
SSLHandshakeException
is a subclass of the IOException
, so you do not need to catch is explicitly. Most developers will not need an explicit catch, but it may help you more easily diagnose the cause of any IOException.
When applying the -Djavax.net.debug=all
property, the failure associated with this SSLHandshakeException
would appear immediately after algorithm negotiation in the logs.
So, System.setProperty("javax.net.debug", "all");
is making error in your code.
What is the root cause of occuring SSLHandshakeException? How to prevent it?
Ans:
The most likely cause for SSLHandshakeException is algorithm support. The JDK provides a separate package called JCE Unlimited Strength, designed to add stronger algorithm support than what’s available by default. Qualys SSL Labs provides a different server SSL test that will enumerate which algorithms a server supports.
Adding stronger algorithms: JCE Unlimited Strength
In a high security environment, one way of strengthening algorithms in the JDK is through the JCE Unlimited Strength policy files. In this particular case, replacing those policy files within JDK 7 allows it to use the stronger variants of existing algorithms and connect successfully.
SSLHandshakeException
is a subclass of the IOException
, so you do not need to catch is explicitly. Most developers will not need an explicit catch, but it may help you more easily diagnose the cause of any IOException.-Djavax.net.debug=all
property, the failure associated with this SSLHandshakeException
would appear immediately after algorithm negotiation in the logs.System.setProperty("javax.net.debug", "all");
is making error in your code.
What is the root cause of occuring SSLHandshakeException? How to prevent it?
Resource Link:
You can try with it
you need to set certificate, to access the SMTP port.
System.setProperty("javax.net.ssl.trustStore","key");
System.setProperty("javax.net.ssl.trustStorePassword","password");
for generating a KeyStore and TrustStore, follow the tutorial
From Marvin Pinto's answer,
The javax.net.ssl.SSLHandshakeException
exception is usually thrown when the server you're trying to connect to does not have a valid certificate from an authorized CA.
Put simply, the server you're attempting to connect to is most likely using a self-signed certificate and you have to accomodate for that in your Java code. This involves creating a custom KeyStore
, etc. See this Stack Overflow answer for full implementation details.
If you want to clarify your conception completely, then read the tutorial which is for use of SSL with JavaMail.
Related Link:
System.setProperty("javax.net.ssl.trustStore","key");
System.setProperty("javax.net.ssl.trustStorePassword","password");
javax.net.ssl.SSLHandshakeException
exception is usually thrown when the server you're trying to connect to does not have a valid certificate from an authorized CA.This involves creating a custom KeyStore
, etc. See this Stack Overflow answer for full implementation details.
If you want to clarify your conception completely, then read the tutorial which is for use of SSL with JavaMail.
No comments:
Post a Comment