Skip to content

Commit 58788b9

Browse files
authored
Merge pull request #28 from lstellway/feature/add-mac-v3-ca
Add ability to specify CA extensions
2 parents dace3d4 + ea77571 commit 58788b9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

self-signed-ssl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ EXIT_CODE=0
2323
CA_KEY=""
2424
CA=""
2525
CA_ONLY=""
26+
CA_EXT=""
2627
TRUST=""
2728
SUBJ=""
2829

@@ -141,6 +142,7 @@ _help() {
141142
--ca-key Path to certificate authority key file
142143
(Generates new CA if not set)
143144
--ca-only Instructs script to solely generate a certificate authority
145+
--ca-ext Allow passing extensions to the CA request
144146
-t|--trust Flag to trust certificate authority
145147
(Do not set for default 'false')
146148
@@ -205,6 +207,7 @@ _parse_args() {
205207
--ca|--ca-cert) CA="${VALUE}";;
206208
--ca-key) CA_KEY="${VALUE}";;
207209
--ca-only) CA_ONLY=1;;
210+
--ca-ext) CA_EXT="${VALUE}";;
208211
-t|--trust) TRUST=1;;
209212
# CSR
210213
--csr) CSR="${VALUE}";;
@@ -457,9 +460,15 @@ _build_ca() {
457460
return
458461
fi
459462

463+
EXT=""
464+
if [ -n "${CA_EXT}" ]; then
465+
EXT="-extensions ${CA_EXT}"
466+
fi
467+
460468
# Generate certificate authority files
461469
openssl genrsa -out "${CA_KEY}" "${BITS}"
462470
openssl req -new -nodes -x509 -sha256 \
471+
$(printf "%s" "${EXT}") \
463472
-subj "${SUBJ}" \
464473
-days "${DAYS}" \
465474
-key "${CA_KEY}" \

0 commit comments

Comments
 (0)