I would like to monitor a simple url. But when its a https server I get a handshake exception. Its possible to verify state of a https url the way browser use to connect? (without having a local certificate). I don't know how browsers do to get content from a https url but I would like to make it the same way. Without need to store a specific certificate for each server. The https being monitored should be anyone.
try {
URL u = new URL(row.getUrl());
String protocol = u.getProtocol();
if(protocol.equals("https")) {
HttpsURLConnection hc = (HttpsURLConnection)u.openConnection();
System.out.println("Response Code: " + hc.getResponseCode());
hc.disconnect();
}
if(protocol.equals("http")) {
u.openConnection();
u.getContent();
}
System.out.println("url is up.");
} catch (Exception e) {
(...)
}