On a M1 iMac system to import a key to use with Java or a IDE like jGRASP use command sudo keytool -importcert -keystore after path to java keystore example here and path to certificate you want to import in my example I have pfsense SSL certificate for use with the proxy and firewall.
sudo keytool -importcert -keystore
/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/lib/security/cacerts
-storepass changeit -file ~/Downloads/SquidCA.crt -alias "root_cert" /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/lib/security/cacerts
On a M1 iMAC to list what is in the certificate store for Java:
keytool -list -keystore
"/Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/lib/security/cacerts"
Warning: use -cacerts option to access cacerts keystore
default password is changeit
After reinstall jGRASP or what IDE you use and it functions with java code like,
URL news = new URL("https://moxie.foxnews.com/feedburner/world.xml/");
BufferedReader in = new BufferedReader(new
InputStreamReader(news.openStream()));
Image: Java program running with trusted root SSL cert installed using https URL. URL seen in both proxy Pfsense Firewall and jGRASP IDE
again, yes Java JDK tools can work with SSL self signed certs.
It also works in Windows 11 just use Oracle's JDK kit path
C:\Program Files\Java\jdk-20\lib\security\cacerts
tool path
C:\Program Files\Java\jdk-20\bin\keytool
I just drop the cert I need into the folder named security and run similar commands as the imac just different paths.
Example:
Windows 10 Example of Use
Java Root Cert Now added
What I like about this is when I am testing Java code with import statements the firewall can see any one offs or any http https get requests that occur that shouldn't in large source code. If something is hidden in an import item now the firewall can see it.