Skip to content
Snippets Groups Projects
Commit eb601ab4 authored by nimrod's avatar nimrod
Browse files

Sign to the short fqdn, add alternative names, correct tests.

parent d9621fa7
No related branches found
No related tags found
No related merge requests found
...@@ -14,17 +14,17 @@ test: clean ...@@ -14,17 +14,17 @@ test: clean
./ssl-ca gen www ./ssl-ca gen www
test "$$(openssl rsa -noout -check -in keys/www)" = "RSA key ok" test "$$(openssl rsa -noout -check -in keys/www)" = "RSA key ok"
openssl verify -CAfile CA.crt certs/www openssl verify -CAfile CA.crt certs/www
test "$$(openssl x509 -in certs/www -issuer -noout)" = "issuer= /CN=*.*.ssl-ca" test "$$(openssl x509 -in certs/www -issuer -noout)" = "issuer= /CN=ssl-ca"
test "$$(openssl x509 -in certs/www -subject -noout)" = "subject= /CN=*.*.www.ssl-ca" test "$$(openssl x509 -in certs/www -subject -noout)" = "subject= /CN=www.ssl-ca"
openssl genrsa -out keys/smtp openssl genrsa -out keys/smtp
./ssl-ca sign ./ssl-ca sign
openssl verify -CAfile CA.crt certs/smtp openssl verify -CAfile CA.crt certs/smtp
test "$$(openssl x509 -in certs/smtp -issuer -noout)" = "issuer= /CN=*.*.ssl-ca" test "$$(openssl x509 -in certs/smtp -issuer -noout)" = "issuer= /CN=ssl-ca"
test "$$(openssl x509 -in certs/smtp -subject -noout)" = "subject= /CN=*.*.smtp.ssl-ca" test "$$(openssl x509 -in certs/smtp -subject -noout)" = "subject= /CN=smtp.ssl-ca"
./ssl-ca resign ./ssl-ca resign
openssl verify -CAfile CA.crt certs/www openssl verify -CAfile CA.crt certs/www
openssl verify -CAfile CA.crt certs/smtp openssl verify -CAfile CA.crt certs/smtp
test "$$(openssl x509 -in certs/www -issuer -noout)" = "issuer= /CN=*.*.ssl-ca" test "$$(openssl x509 -in certs/www -issuer -noout)" = "issuer= /CN=ssl-ca"
test "$$(openssl x509 -in certs/www -subject -noout)" = "subject= /CN=*.*.www.ssl-ca" test "$$(openssl x509 -in certs/www -subject -noout)" = "subject= /CN=www.ssl-ca"
test "$$(openssl x509 -in certs/smtp -issuer -noout)" = "issuer= /CN=*.*.ssl-ca" test "$$(openssl x509 -in certs/smtp -issuer -noout)" = "issuer= /CN=ssl-ca"
test "$$(openssl x509 -in certs/smtp -subject -noout)" = "subject= /CN=*.*.smtp.ssl-ca" test "$$(openssl x509 -in certs/smtp -subject -noout)" = "subject= /CN=smtp.ssl-ca"
#!/bin/sh -e #!/bin/sh -e
test $(which openssl) || ( echo "Can't find openssl."; exit 1) test $(which openssl) || ( echo "Can't find openssl."; exit 1)
export domain="$(basename $PWD)"
seed="$(hexdump -n10 -e '10/1 "%02o" "\n"' /dev/urandom)" seed="$(hexdump -n10 -e '10/1 "%02o" "\n"' /dev/urandom)"
config=\ config=\
"[ ca ] "[ ca ]
...@@ -33,13 +32,15 @@ RANDFILE = /dev/urandom ...@@ -33,13 +32,15 @@ RANDFILE = /dev/urandom
#O = Organization name #O = Organization name
#OU = Organizational unit #OU = Organizational unit
#emailAddress = email address #emailAddress = email address
CN = *.*.\${ENV::domain} CN = \${ENV::domain}
[ v3_ca ] [ v3_ca ]
basicConstraints = CA:true basicConstraints = CA:true
subjectAltName = DNS:*.\${ENV::domain}, DNS:*.*.\${ENV::domain}
[ v3_req ] [ v3_req ]
basicConstraints = CA:false basicConstraints = CA:false
subjectAltName = DNS:*.\${ENV::domain}
" "
usage () { usage () {
...@@ -47,6 +48,7 @@ usage () { ...@@ -47,6 +48,7 @@ usage () {
} }
init () { init () {
export domain="$(basename $PWD)"
mkdir -p certs keys mkdir -p certs keys
if [ -e openssl.cnf ] if [ -e openssl.cnf ]
then then
...@@ -92,6 +94,7 @@ sign_key () { ...@@ -92,6 +94,7 @@ sign_key () {
openssl req \ openssl req \
-key keys/$1 \ -key keys/$1 \
-new \ -new \
-reqexts v3_req \
-config openssl.cnf \ -config openssl.cnf \
-out "$csr" -out "$csr"
openssl x509 \ openssl x509 \
...@@ -101,6 +104,7 @@ sign_key () { ...@@ -101,6 +104,7 @@ sign_key () {
-CA CA.crt \ -CA CA.crt \
-set_serial $seed \ -set_serial $seed \
-extensions v3_req \ -extensions v3_req \
-extfile openssl.cnf \
-CAkey CA.key -CAkey CA.key
rm "$csr" rm "$csr"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment