Created
April 8, 2025 01:39
-
-
Save scolton99/8843b488e1f5e95d21a8a9db938955a4 to your computer and use it in GitHub Desktop.
Certificate Generators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
if test -f ".req.conf" | |
rm .req.conf | |
end | |
set STRBASE "[req] | |
distinguished_name = dn | |
x509_extensions = v3_req | |
prompt = no | |
[dn] | |
C = US | |
ST = Illinois | |
L = Chicago | |
O = Northwestern University | |
OU = Information Technology | |
CN = $argv[1] | |
[v3_req] | |
keyUsage = keyEncipherment, nonRepudiation, digitalSignature, dataEncipherment, keyAgreement, keyCertSign | |
extendedKeyUsage = serverAuth | |
basicConstraints = CA:true | |
subjectKeyIdentifier = hash | |
authorityKeyIdentifier = keyid:always,issuer:always | |
subjectAltName = @alt_names | |
[alt_names]" | |
set C 1 | |
for var in $argv | |
echo $var | |
set STRBASE $STRBASE\n"DNS.$C = $var" | |
set C (math "$C + 1") | |
end | |
echo -e "$STRBASE" >> .req.conf | |
openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout "$argv[1].key" -days 730 -out "$argv[1].crt" -config .req.conf | |
openssl pkcs12 -export -out "$argv[1].pfx" -inkey "$argv[1].key" -in "$argv[1].crt" | |
# rm .req.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -f ".req.conf" ]; then | |
rm .req.conf | |
fi | |
STRBASE="[req]\ndistinguished_name = dn\nx509_extensions = v3_req\nprompt = no\n\n[dn]\nC = US\nST = Illinois\nL = Chicago\nO = Northwestern University\nOU = Information Technology\nCN = $1\n\n[v3_req]\nkeyUsage = keyEncipherment, nonRepudiation, digitalSignature, dataEncipherment, keyAgreement, keyCertSign\nextendedKeyUsage = serverAuth\nsubjectKeyIdentifier = hash\nauthorityKeyIdentifier = keyid:always,issuer:always\nsubjectAltName = @alt_names\n\n[alt_names]" | |
C=1 | |
for var in "$@" | |
do | |
STRBASE="${STRBASE}\nIP.${C} = ${var}" | |
C=$(( $C + 1 )) | |
done | |
echo -e $STRBASE >> .req.conf | |
openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout $1.key -days 8395 -out $1.crt -config .req.conf | |
openssl pkcs12 -export -out $1.pfx -inkey $1.key -in $1.crt | |
rm .req.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -f ".req.conf" ]; then | |
rm .req.conf | |
fi | |
STRBASE="[req]\ndistinguished_name = dn\nx509_extensions = v3_req\nprompt = no\n\n[dn]\nO = USAA\nCN = $1\n\n[v3_req]\nkeyUsage = critical, digitalSignature, keyCertSign, cRLSign\nbasicConstraints = CA:true\nsubjectKeyIdentifier = hash\n" | |
# C=1 | |
# for var in "$@" | |
# do | |
# STRBASE="${STRBASE}\nDNS.${C} = ${var}" | |
# C=$(( $C + 1 )) | |
# done | |
echo -e $STRBASE >> .req.conf | |
openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout $1.key -days 8395 -out $1.crt -config .req.conf | |
openssl pkcs12 -export -out $1.pfx -inkey $1.key -in $1.crt | |
rm .req.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment