I make an HttpsURLConnection
as below:
try
{
URL url = new URL( host );
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.connect();
logger.debug( httpURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK );
}
catch ( Exception ex )
{
logger.error( ex.getMessage() );
}
The host
I tested doesn't have a valid certificate, so when I tested within Eclipse, it catch SSLHandshakeException
which its fine.
However, when I deployed as WebStart, it doesn't go to catch clause but showing me the warning dialog instead:
If user click Continue, it passes the connect()
successfully.
Is there anyway that I can catch the exception instead allowing User to click Continue from this dialog ?
To disable the dialog use this:
connection.setAllowUserInteraction(false);
Now you should get the exception immediately if the JVM is not happy with the certificate.