5.4. Add a Certificate to a Java Keystore

Prerequisites:

To add a certificate to a given Java keystore, execute the commands below, replacing CACERTS with the correct path and CA_CERT_PATH with the path to the certificate file and CERTIFICATE_NICKNAME with a certificate nickname. If prompted Password:, enter your machine password. If prompted Enter keystore password, the default is typically changeit. If prompted, Trust this certificate?, enter yes.

CACERTS='CACERTS'
        
sudo keytool \
    -importcert \
    -file 'CA_CERT_PATH' \
    -alias 'CERTIFICATE_NICKNAME' \
    -trustcacerts \
    -keystore "${CACERTS}"