Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpenSSL 3 breaks PKCS12 tmp file generation #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 12 additions & 2 deletions unifi_ssl_import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,30 @@ fi
# Export your existing SSL key, cert, and CA data to a PKCS12 file
printf "\nExporting SSL certificate and key data into temporary PKCS12 file...\n"

# Check for OpenSSL 3.x
OPENSSL_VERSION=$(openssl version -v | awk '{print $2}'| awk -F '.' '{print $1}')
if [[ "${OPENSSL_VERSION}" -ge '3' ]]; then
OPENSSL_LEGACY_FLAG='-legacy'
else
OPENSSL_LEGACY_FLAG=
fi

#If there is a signed crt we should include this in the export
if [[ -f ${SIGNED_CRT} ]]; then
openssl pkcs12 -export \
-in "${CHAIN_FILE}" \
-in "${SIGNED_CRT}" \
-inkey "${PRIV_KEY}" \
-out "${P12_TEMP}" -passout pass:"${PASSWORD}" \
-name "${ALIAS}"
-name "${ALIAS}" \
${OPENSSL_LEGACY_FLAG}
else
openssl pkcs12 -export \
-in "${CHAIN_FILE}" \
-inkey "${PRIV_KEY}" \
-out "${P12_TEMP}" -passout pass:"${PASSWORD}" \
-name "${ALIAS}"
-name "${ALIAS}" \
${OPENSSL_LEGACY_FLAG}
fi

# Delete the previous certificate data from keystore to avoid "already exists" message
Expand Down