Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ that which is already setup via configuration files. To use:
alternate distinguished name matching policies for signing your
certificate. When unset, defaults from your configuration file are
used.
* `PKICTL_CA_DAYS`: set this prior to signing commands to override the
number of days to certify a certificate for as set on the config file.
* PKCS#12 Import Settings
* `$PKICTL_SSL_DIR`: defaults to `/etc/ssl`, make sure this coincides
with where your operating system's OpenSSL installation stores its
Expand Down
24 changes: 16 additions & 8 deletions pkictl
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,30 @@ sign_root_ca_request() {
openssl ca -selfsign \
-config "$conf" \
-in "${caPath}/${csrName}.csr" \
-out "${caPath}/${outName}.crt"
-out "${caPath}/${outName}.crt" \
-days "$PKICTL_CA_DAYS"
elif [[ "$PKICTL_CA_EXTENSIONS" != "" ]] && [[ "$PKICTL_CA_POLICY" == "" ]]; then
openssl ca -selfsign \
-config "$conf" \
-in "${caPath}/${csrName}.csr" \
-out "${caPath}/${outName}.crt" \
-extensions "$PKICTL_CA_EXTENSIONS"
-extensions "$PKICTL_CA_EXTENSIONS" \
-days "$PKICTL_CA_DAYS"
elif [[ "$PKICTL_CA_EXTENSIONS" == "" ]] && [[ "$PKICTL_CA_POLICY" != "" ]]; then
openssl ca -selfsign \
-config "$conf" \
-in "${caPath}/${csrName}.csr" \
-out "${caPath}/${outName}.crt" \
-policy "$PKICTL_CA_POLICY"
-policy "$PKICTL_CA_POLICY" \
-days "$PKICTL_CA_DAYS"
else
openssl ca -selfsign \
-config "$conf" \
-in "${caPath}/${csrName}.csr" \
-out "${caPath}/${outName}.crt" \
-policy "$PKICTL_CA_POLICY" \
-extensions "$PKICTL_CA_EXTENSIONS"
-extensions "$PKICTL_CA_EXTENSIONS" \
-days "$PKICTL_CA_DAYS"
fi

if [[ "$?" -eq 0 ]]; then
Expand All @@ -135,26 +139,30 @@ sign_request() {
openssl ca \
-config "$conf" \
-in "$inCsr" \
-out "$outCrt"
-out "$outCrt" \
-days "$PKICTL_CA_DAYS"
elif [[ "$PKICTL_CA_EXTENSIONS" != "" ]] && [[ "$PKICTL_CA_POLICY" == "" ]]; then
openssl ca \
-config "$conf" \
-in "$inCsr" \
-out "$outCrt" \
-extensions "$PKICTL_CA_EXTENSIONS"
-extensions "$PKICTL_CA_EXTENSIONS" \
-days "$PKICTL_CA_DAYS"
elif [[ "$PKICTL_CA_EXTENSIONS" == "" ]] && [[ "$PKICTL_CA_POLICY" != "" ]]; then
openssl ca \
-config "$conf" \
-in "$inCsr" \
-out "$outCrt" \
-policy "$PKICTL_CA_POLICY"
-policy "$PKICTL_CA_POLICY" \
-days "$PKICTL_CA_DAYS"
else
openssl ca \
-config "$conf" \
-in "$inCsr" \
-out "$outCrt" \
-policy "$PKICTL_CA_POLICY" \
-extensions "$PKICTL_CA_EXTENSIONS"
-extensions "$PKICTL_CA_EXTENSIONS" \
-days "$PKICTL_CA_DAYS"
fi

if [[ "$?" -eq 0 ]]; then
Expand Down