These are the instructions to make your program work. Btw, I am on windows, using google chrome.
You do need a certificate.
1) First, go to the url (doesn't matter if it's a website or a restful service), let's pick google.com. Right click on the page and click "inspect".
2) Go to the security tab.
3) Once, you're there, click "view certificate".
A window will pop up, with site's certificate's details.
4) Go to the "certification path" tab. And double click on the certificate that you want from the hierarchy.
A new window will pop up:
I chose the root certificate in this case called "Google trust services...", but you can choose a more specific one, like "Google Internet Authority G3". I think the more specific it is, the more security it provides (but I'm not sure).
5) Go to the "Details" tab and choose your certificate's name:
6) Click "Copy To File", then choose the name for it and where you want to save it. I saved mine on desktop and named it "test.cer".
Now you are done exporting the certificate. Next, you want to add it to jvm's truststore.
1) Look up which JRE your application is running on, for example I have only one JRE on my computer (excluding the one bundled with the JDK). It's located here:
The target file that stores certificates is cacerts:
2) Open cmd as administrator and do cd "C:Program FilesJavajre-10.0.1libsecurity"
(path to cacerts in my case).
3) Issue the following command:
keytool -import -storepass changeit -noprompt -alias *alias* -keystore cacerts -trustcacerts -file *path_to_certificate*
Note that alias can be anything, regardless of what you called your file, as long as it doesn't clash with aliases of other certificates already in the truststore.
In my case I issue this:
4) You can now issue this command: keytool -list -keystore cacerts -alias *alias*
to make sure your certificate was added. When you issue this command, it will ask you for your password. In step three, the command I gave your had this option: -storepass changeit
, so your password will be changeit
.
In my case everything is okay.
5) Now you can restart your application and it should work. Some people recommend restarting your computer, but I don't know if that's necessary.