RESTClient is a great little CLI and GUI tool for testing your REST API. I recently pushed a new API up in the office and it runs over SSL. I tried to test it in the RESTClient and got a PeerNotVerified error from Java. First thing I did was go to the SSL tab in RestClient presuming I could tell it to just trust the API…apparently not.
So after a bit of web scouring about how to get Java to trust your site I came across instructions and thought I’d re-post here simplified for anyone who needs to query HTTPS from RESTClient.
These instructions are based on Windows 64-bit and Java being installed into C:Program Files (x86)Java. So you may have to change a few paths but the core things are the same.
Navigate to the website in your browser, click the SSL icon in the address bar and click Certificate Information or Details etc.In the window that pops up, go to the Details tab then click the “Copy to File” button. Click Next until you get to the request for a Filename. Click Browse and navigate to “C:Program Files (x86)Javajre6libsecurity”. Enter the filename to save the certificate as (I suggest the domain name with .cer ending). Finally click Next and Finish.
Now open up a command prompt (if you’ve got Windows security then be sure to run as administrator [right click the shortcut to the command prompt and the option is there]) and enter the following:
cd "C:\Program Files (x86)\Java\jre6" bin\keytool.exe -noprompt -import -keystore libsecuritycacerts -alias (put_domain_name_here) -file libsecurity(name_of_certificate_you_saved_above).cer
The second command should all be on one line. You’ll get asked for a password, if you’ve never touched any Java passwords on your machine before, it’ll probably be the certificate store default which is either changeit or changeme.
That’s it! You should now be able to query your service using HTTPS without any errors.