@@ -3661,9 +3661,12 @@ Missing User Certificate, expected at:
3661
3661
fi
3662
3662
3663
3663
# Complete export
3664
+ inline_out=
3665
+ inline_msg=
3664
3666
case "$pkcs_type" in
3665
3667
p12)
3666
3668
pkcs_out="$EASYRSA_PKI/private/$file_name_base.p12"
3669
+ inline_out="$EASYRSA_PKI/inline/$file_name_base-p12.inline"
3667
3670
3668
3671
[ "$legacy" ] && \
3669
3672
error_info="SSL library may not support -legacy mode"
@@ -3682,6 +3685,37 @@ Missing User Certificate, expected at:
3682
3685
${EASYRSA_PASSIN:+ -passin "$EASYRSA_PASSIN"} \
3683
3686
${EASYRSA_PASSOUT:+ -passout "$EASYRSA_PASSOUT"} \
3684
3687
|| die "Failed to export PKCS#12"
3688
+
3689
+ # Inline .p12 only
3690
+ # Get cert CN
3691
+ inline_CN="$(
3692
+ "$EASYRSA_OPENSSL" x509 -in "$crt_in" -noout -subject \
3693
+ -nameopt multiline,-esc_msb | grep 'commonName'
3694
+ )" || die "export_pkcs - inline_CN FAILED"
3695
+ inline_CN="${inline_CN##*= }"
3696
+
3697
+ # BASE64 encode pkcs12
3698
+ inline_tmp=
3699
+ easyrsa_mktemp inline_tmp || die "export_pkcs - inline_tmp"
3700
+ if "$EASYRSA_OPENSSL" enc -a -in "$pkcs_out" > "$inline_tmp"
3701
+ then
3702
+ # make inline file
3703
+ {
3704
+ print "\
3705
+ # Easy-RSA inline file: pkcs12
3706
+ # commonName: ${inline_CN}${NL}"
3707
+ print "<pkcs12>"
3708
+ cat "$inline_tmp"
3709
+ print "</pkcs12>"
3710
+ } > "$inline_out" || die "export_pkcs - make inline"
3711
+
3712
+ inline_msg="\
3713
+ A BASE64 encoded inline file has also been created at:
3714
+ * ${inline_out}${NL}"
3715
+ else
3716
+ inline_msg="\
3717
+ Failed to create a BASE64 encoded inline file${NL}"
3718
+ fi
3685
3719
;;
3686
3720
p7)
3687
3721
pkcs_out="$EASYRSA_PKI/issued/$file_name_base.p7b"
@@ -3731,9 +3765,11 @@ Missing User Certificate, expected at:
3731
3765
*) die "Unknown PKCS type: $pkcs_type"
3732
3766
esac
3733
3767
3768
+ # User messages
3734
3769
notice "\
3735
3770
Successful export of $pkcs_type file. Your exported file is at:
3736
3771
* $pkcs_out"
3772
+ [ "$inline_msg" ] && print "$inline_msg"
3737
3773
3738
3774
return 0
3739
3775
} # => export_pkcs()
0 commit comments