Skip to content

Instantly share code, notes, and snippets.

@gturi
Created January 19, 2021 21:20
Show Gist options
  • Select an option

  • Save gturi/4d1781cb8907fde49b406bf9ed8d2f4b to your computer and use it in GitHub Desktop.

Select an option

Save gturi/4d1781cb8907fde49b406bf9ed8d2f4b to your computer and use it in GitHub Desktop.
add and remove jvm cacerts

Manage jvm cacerts

Add certificate

#!/bin/bash


JAVA_FOLDER='/opt/jdk1.8.0_271' # TODO change according to your system

CERT_PATH="/path/to/certificate.pem"
CERT_NAME=${CERT_PATH##*/}

KEYSTORE_PATH="$JAVA_FOLDER/jre/lib/security/cacerts"
KEYTOOL="$JAVA_FOLDER/bin/keytool"

"$KEYTOOL" -import -alias "$CERT_NAME" -keystore "$KEYSTORE_PATH" -file "$CERT_PATH"

Remove certificate

#!/bin/bash

JAVA_FOLDER='/opt/jdk1.8.0_271' # TODO change according to your system

CERT_PATH="/path/to/certificate.pem"
CERT_NAME=${CERT_PATH##*/}

KEYSTORE_PATH="$JAVA_FOLDER/jre/lib/security/cacerts"
KEYTOOL="$JAVA_FOLDER/bin/keytool"

"$KEYTOOL" -delete -alias "$CERT_NAME" -keystore "$KEYSTORE_PATH" -storepass changeit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment