...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#!/bin/bash # Set the environment PRIVATE_KEY_ES256=$1.pem PUBLIC_KEY_ES256=$2.pem CLIENT_NAME=DAS # Generates the ES256 keys openssl ecparam -genkey -name prime256v1 -noout -out "${PRIVATE_KEY_ES256}" # Extracts the public key openssl ec -in "${PRIVATE_KEY_ES256}" -pubout -out "${PUBLIC_KEY_ES256}" # Generates an x509 certificate CERT_KEY_ES256=es256_cert.pem OPENSSL_CONF=./openssl.cnf CERT_CN="${CLIENT_NAME} private_key_jwt authentication" # Build the certificate config file printf '[ req ]\n' > "${OPENSSL_CONF}" printf 'prompt = no\n' >> "${OPENSSL_CONF}" printf 'distinguished_name = req_distinguished_name\n' >> "${OPENSSL_CONF}" printf '[ req_distinguished_name ]\n' >> "${OPENSSL_CONF}" printf 'CN = %s\n' "${CERT_CN}" >> "${OPENSSL_CONF}" # Creates the x509 certificate openssl req -x509 -new -config "${OPENSSL_CONF}" -key "${PRIVATE_KEY_ES256}" -out "${CERT_KEY_ES256}" |
...