@@ -2904,10 +2904,9 @@ $(cat "$crt_source")
29042904</cert>"
29052905
29062906 # Calculate decimal value for serial number
2907- # because openvpn uses decimal serial ?!?
2907+ # because openvpn uses decimal serial
29082908 # for '--crl-verify /path/to/dir dir'
2909- # For reasons unknown..
2910- if which bc >/dev/null; then
2909+ if which bc 1>/dev/null 2>&1; then
29112910 inline_crt_serial=
29122911 ssl_cert_serial "$crt_source" inline_crt_serial || \
29132912 die "inline_file - ssl_cert_serial"
@@ -2927,6 +2926,7 @@ $(cat "$crt_source")
29272926 crt_fingerprint="${crt_fingerprint#*=}"
29282927
29292928 # Certificate type
2929+ inline_crt_type=
29302930 ssl_cert_x509v3_eku "$crt_source" inline_crt_type || \
29312931 die "inline_file: Failed to set inline_crt_type"
29322932
@@ -3615,11 +3615,12 @@ Run easyrsa without commands for usage and command help."
36153615 # OpenSSL 3.0 without needing '-legacy'.
36163616 if [ "$openssl_v3" ]; then
36173617 # No cipher opts required
3618- p12_cipher_opts=""
3618+ unset -v p12_keypbe p12_certpbe p12_macalg
36193619 else
36203620 # Upgrade PBE & MAC opts - Reset by option 'legacy'
3621- p12_cipher_opts="-keypbe AES-256-CBC -certpbe AES-256-CBC"
3622- p12_cipher_opts="${p12_cipher_opts} -macalg sha256"
3621+ p12_keypbe=AES-256-CBC
3622+ p12_certpbe=AES-256-CBC
3623+ p12_macalg=sha256
36233624 fi
36243625
36253626 while [ "$1" ]; do
@@ -3642,10 +3643,12 @@ Run easyrsa without commands for usage and command help."
36423643 ;;
36433644 legacy)
36443645 if [ "$openssl_v3" ]; then
3646+ # OpenSSL v3 requires providers/legacy.so
3647+ # EasyRSA can use OPENSSL_MODULES=/path-to/providers
36453648 legacy=-legacy
36463649 else
36473650 # Downgrade PBE & MAC opts
3648- p12_cipher_opts=""
3651+ unset -v p12_keypbe p12_certpbe p12_macalg
36493652 fi
36503653 ;;
36513654 *)
@@ -3758,25 +3761,30 @@ Missing User Certificate, expected at:
37583761 fi
37593762
37603763 # Complete export
3761- inline_out=
37623764 inline_msg=
37633765 case "$pkcs_type" in
37643766 p12)
3765- pkcs_out="$EASYRSA_PKI/private/$file_name_base.p12"
3766- inline_out="$EASYRSA_PKI/inline/$file_name_base-p12.inline"
3767+ pkcs_out="${EASYRSA_PKI}/private/${file_name_base}.p12"
3768+ # Only PKCS12 can be inlined for OpenVPN
3769+ inline_dir="$EASYRSA_PKI"/inline/private
3770+ inline_out="${inline_dir}/${file_name_base}".inline-p12
37673771
37683772 [ "$legacy" ] && \
37693773 error_info="SSL library may not support -legacy mode"
37703774
3775+ verbose "export-p12: cipher opts: \
3776+ -keypbe=$p12_keypbe | -certpbe=$p12_certpbe | -macalg=$p12_macalg"
3777+
37713778 # export the p12:
3772- # shellcheck disable=2086 # Double quote p12_cipher_opts
37733779 easyrsa_openssl pkcs12 -export \
37743780 -in "$crt_in" \
37753781 -out "$pkcs_out" \
37763782 -inkey "$key_in" \
37773783 ${nokeys} \
37783784 ${legacy} \
3779- ${p12_cipher_opts} \
3785+ ${p12_keypbe:+ -keypbe "$p12_keypbe"} \
3786+ ${p12_certpbe:+ -certpbe "$p12_certpbe"} \
3787+ ${p12_macalg:+ -macalg "$p12_macalg"} \
37803788 ${friendly_name:+ -name "$friendly_name"} \
37813789 ${want_ca:+ -certfile "$crt_ca"} \
37823790 ${EASYRSA_PASSIN:+ -passin "$EASYRSA_PASSIN"} \
0 commit comments