Last active
November 19, 2020 13:53
-
-
Save ntkathole/d6f15b984fd5851ccf6c54c059c400fb to your computer and use it in GitHub Desktop.
Script to generate certificates for satellite server
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
country=IN | |
state=Maharashtra | |
locality=Pune | |
organization=redhat | |
organizationalunit=QE | |
commonname=$(hostname) | |
openssl genrsa -out rootCA.key 2048 | |
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname" | |
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname" | |
echo "authorityKeyIdentifier=keyid,issuer" > x509.ext | |
echo "basicConstraints=CA:FALSE" >> x509.ext | |
echo "keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment" >> x509.ext | |
echo "subjectAltName = @alt_names" >> x509.ext | |
echo "[alt_names]" >> x509.ext | |
echo "DNS.1 = localhost" >> x509.ext | |
openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.valid.crt -days 100 -sha256 -extfile x509.ext | |
echo "Reading generated certificate :: " | |
openssl x509 -text -in server.valid.crt -noout | |
katello-certs-check -c server.valid.crt -k server.key -b rootCA.pem |
Hello, how about s/-days 100/-days 365/ in ist.github.com/ntkathole/d6f15b984fd5851ccf6c54c059c400fb#file-satellite_cert_generator-sh-L17
Thank you
Due to the fix of below Bugzilla in 6.9 snap 1, now certs generated above this script will fail in katello-check-certs as 'Alt name DNS' will not have the hostname of the Satellite.
https://bugzilla.redhat.com/show_bug.cgi?id=1887504
to fix, we need to change echo "DNS.1 = localhost" >> x509.ext
to echo "DNS.1 = $commonname" >> x509.ext
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#! /bin/bash
if [ -n "$1" ]; then
name=$1
else
name=$(hostname)
fi
git clone https://github.com/ntkathole/ownca.git
cd ownca
yes "" | ./generate-ca.sh
yes | ./generate-crt.sh $name
certdir="$(pwd)/$name/"
cp cacert.crt $name/
cd $name
katello-certs-check -c "$name.crt" -k "$name.key" -b cacert.crt