Keytool import export

I am trying to launch ShinyProxy in a docker container.

If I run key tool then launch ShinyProxy, the keystore is loaded, however if I try to export the certificate save it in a pem file and reload it, ShinyProxy won’t load the keystore and errors out. This is important because the keytool isn’t deterministic, and generates a different certificate each run.

rm samlKeystore.jks

keytool -deststoretype pkcs12
-genkeypair
-keyalg RSA
-keysize 4096
-sigalg SHA256withRSA
-validity 1460
-alias shinyproxy-saml
-keystore /home/docker/data/samlKeystore.jks
-storepass:file saml_cert_password -dname “fill in the blanks”

keytool -exportcert -alias shinyproxy-saml -keystore samlKeystore.jks -rfc -file cert.pem -storepass:file saml_cert_password

keytool -importcert -file saml_cert.pem -keystore samlKeystore.jks -alias shinyproxy-saml -storepass:file saml_cert_password -noprompt