forked from jlambert121/jlambert121-trusted_ca
-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from ekohl/el-9-support
Support EL 9: Avoid running update-ca-trust twice
- Loading branch information
Showing
4 changed files
with
36 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,40 @@ | ||
#!/bin/sh | ||
|
||
OUTDIR=/etc/ssl-secure | ||
set -xe | ||
|
||
echodo() | ||
{ | ||
echo "${@}" | ||
(${@}) | ||
} | ||
|
||
C=US | ||
ST=Colorado | ||
L=Denver | ||
O=Example | ||
OU=Test | ||
CN=`hostname` | ||
OUTDIR=${OUTDIR:-/etc/ssl-secure} | ||
CN=$(hostname -f) | ||
|
||
cakey="${OUTDIR}/ca.key" | ||
cacert="${OUTDIR}/ca.crt" | ||
csr="${OUTDIR}/test.csr" | ||
csr_ext="${OUTDIR}/test.v3.ext" | ||
key="${OUTDIR}/test.key" | ||
cert="${OUTDIR}/test.crt" | ||
|
||
mkdir $OUTDIR | ||
mkdir "$OUTDIR" | ||
|
||
# Based on https://arminreiter.com/2022/01/create-your-own-certificate-authority-ca-using-openssl/ | ||
|
||
# Create a CA | ||
openssl genrsa -aes256 -out "$cakey" -passout pass:ca-password 2048 | ||
openssl req -x509 -new -passin pass:ca-password -passout pass:ca-password -key "$cakey" -sha256 -days 1826 -out "$cacert" -subj '/CN=Trusted CA acceptance tests Root CA' | ||
|
||
# Create the certificate signing request | ||
openssl req -new -passin pass:password -passout pass:password -out ${csr} <<EOF | ||
${C} | ||
${ST} | ||
${L} | ||
${O} | ||
${OU} | ||
${CN} | ||
$USER@${CN} | ||
. | ||
. | ||
openssl req -new -passin pass:password -nodes -out "$csr" -newkey rsa:2048 -keyout "$key" -subj "/CN=${CN}" | ||
|
||
# create a v3 ext file for SAN properties | ||
cat > "$csr_ext" << EOF | ||
authorityKeyIdentifier=keyid,issuer | ||
basicConstraints=CA:FALSE | ||
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment | ||
subjectAltName = @alt_names | ||
[alt_names] | ||
DNS.1 = ${CN} | ||
EOF | ||
|
||
[ -f ${csr} ] && echodo openssl req -text -noout -in ${csr} | ||
|
||
# Create the Key | ||
openssl rsa -in privkey.pem -passin pass:password -passout pass:password -out ${key} | ||
# Inspect CSR | ||
openssl req -text -noout -in "$csr" | ||
|
||
# Create the Certificate | ||
openssl x509 -in ${csr} -out ${cert} -req -signkey ${key} -days 1000 | ||
openssl x509 -req -passin pass:ca-password -in "$csr" -CA "$cacert" -CAkey "$cakey" -CAcreateserial -out "$cert" -days 730 -sha256 -extfile "$csr_ext" |