Skip to content

Instantly share code, notes, and snippets.

@aelkz
Forked from wsargent/genca.sh
Created October 28, 2017 13:46
Show Gist options
  • Select an option

  • Save aelkz/d290a4a79714f0f4a822c390fd9fbbd9 to your computer and use it in GitHub Desktop.

Select an option

Save aelkz/d290a4a79714f0f4a822c390fd9fbbd9 to your computer and use it in GitHub Desktop.
Generate a certificate authority and trust anchor keystore, using only keytool
#!/bin/bash
export PW=`cat password`
# Create a self signed key pair root CA certificate.
keytool -genkeypair -v \
-alias exampleca \
-dname "CN=exampleCA, OU=Example Org, O=Example Company, L=San Francisco, ST=California, C=US" \
-keystore exampleca.jks \
-keypass:env PW \
-storepass:env PW \
-keyalg RSA \
-keysize 4096 \
-ext KeyUsage="keyCertSign" \
-ext BasicConstraints:"critical=ca:true" \
-validity 9999
# Export the exampleCA public certificate so that it can be used in trust stores..
keytool -export -v \
-alias exampleca \
-file exampleca.crt \
-keypass:env PW \
-storepass:env PW \
-keystore exampleca.jks \
-rfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment