Add charles ssl proxy certificates to JDK on a mac

First you need to run charles and enable SSL proxying. The see which JDK is used by your application and add the certificate to the cacerts file:

curl -s http://ssl.charles/ --proxy 127.0.0.1:8888 > cert_file
sudo keytool -import -noprompt -alias charles-$(date +%Y%m%d%H%M%S) \
  -file cert_file \
  -keystore /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/lib/security/cacerts \
  -storepass changeit
rm cert_file