Commit 1fee4498 authored by nimrod's avatar nimrod
Browse files

init now creates the key and cert in 2 steps, skipping any file that already exists.

parent eb7def43
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ install:
	chmod 755 /usr/local/bin/ssl-ca

clean:
	rm -rf openssl.cnf certs keys CA.key CA.crt
	rm -rf openssl.cnf certs keys CA.key CA.crt CA.p12

test: clean
	./ssl-ca init
+29 −14
Original line number Diff line number Diff line
@@ -59,20 +59,35 @@ init () {
    else
        echo "$config" > "openssl.cnf"
    fi
    if [ -e CA.key ]
    then
        echo CA.key already exists, skipping.
    else
        openssl genrsa -out CA.key 2048
    fi
    if [ -e CA.crt ]
    then
        echo CA.crt already exists, skipping.
    else
        openssl req \
            -x509 \
            -config openssl.cnf \
            -new \
        -newkey rsa:2048 \
        -keyout CA.key \
            -key CA.key \
            -extensions v3_ca \
            -out CA.crt
    fi
    if [ -e CA.p12 ]
    then
        echo PKCS12 file already exists, skipping.
    else
        openssl pkcs12 \
            -export \
            -in CA.crt \
            -inkey CA.key \
            -out CA.p12 \
            -passout pass:
    fi
}

sign_key () {