I am trying to acces the https xml url of my application deployed on jdk 1.7.0_25 through my groovy code. But the groovy throws an exception for this line in groovy code -
URL url = new URL("https://my.company.com//path/to/xml")
URLConnection urlConnection = url.openConnection()
def xml = new XmlSlurper().parse(url.toString())
//Parse the XML here....and perform operations
exception javax.net.ssl.SSLProtocolException: handshake alert:unrecognized_name
As a workaround I tried importing the certificate - my.company.com from the certificate hierarchy my.company.cer through the browser to my local keystore where I've my development environment setup. Below is the command -
1. keytool -importcert -alias "mycompany-ca" -file my.company.cer
2. keytool -import -file my_company.cer -keystore "C:\Program Files\Java\jdk1.6.0_30\jre\lib\security\cacerts" -trustcacerts -storepass "changeit"
And the certificate was successfully added to the local trust store - "jdk1.6.0_30\jre\lib\security\cacerts". I was able to access the xml via https url via groovy code then. So I tried further importing the same certificate in the server environment's local keystore.
But the problem is this workaround works randomly. Sometimes I am able to access this xml successfully via https url from the server and sometimes I hit the same error randomly without any change in the script.
Do I need to import the root certificate into the local trust store of my server environment?
How do I handle this SSL exception in my groovy itself?
I am sorry I am complete new to this. Any pointers and help would be much appreciated.