Skip to content

Commit

Permalink
Merge pull request #28 from lstellway/feature/add-mac-v3-ca
Browse files Browse the repository at this point in the history
Add ability to specify CA extensions
  • Loading branch information
lstellway authored Jul 13, 2021
2 parents dace3d4 + ea77571 commit 58788b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions self-signed-ssl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ EXIT_CODE=0
CA_KEY=""
CA=""
CA_ONLY=""
CA_EXT=""
TRUST=""
SUBJ=""

Expand Down Expand Up @@ -141,6 +142,7 @@ _help() {
--ca-key Path to certificate authority key file
(Generates new CA if not set)
--ca-only Instructs script to solely generate a certificate authority
--ca-ext Allow passing extensions to the CA request
-t|--trust Flag to trust certificate authority
(Do not set for default 'false')
Expand Down Expand Up @@ -205,6 +207,7 @@ _parse_args() {
--ca|--ca-cert) CA="${VALUE}";;
--ca-key) CA_KEY="${VALUE}";;
--ca-only) CA_ONLY=1;;
--ca-ext) CA_EXT="${VALUE}";;
-t|--trust) TRUST=1;;
# CSR
--csr) CSR="${VALUE}";;
Expand Down Expand Up @@ -457,9 +460,15 @@ _build_ca() {
return
fi

EXT=""
if [ -n "${CA_EXT}" ]; then
EXT="-extensions ${CA_EXT}"
fi

# Generate certificate authority files
openssl genrsa -out "${CA_KEY}" "${BITS}"
openssl req -new -nodes -x509 -sha256 \
$(printf "%s" "${EXT}") \
-subj "${SUBJ}" \
-days "${DAYS}" \
-key "${CA_KEY}" \
Expand Down

0 comments on commit 58788b9

Please sign in to comment.