Create a pfx file with a certificate chain

I ran into an issue where an application would not accept the pfx file that I created for a web server.  I used the key file and the certificate file but for some reason it did not work. I had to include the certificate chain which had the root CA and intermediate certificates combined in it.

If you don’t have the Intermediate/Root certificates you can export them from your certificate file (.crt). Just double click on it, go to Certification path tab, select root CA (very top one) > View certificate, then details tab of the Root CA certificate > Copy to File > Base 64 encoded X.509 and call it Root.crt. Do the same for intermediate and save it as intermediate.crt.

Creating a PFX file with a chain
===================================

C:\OpenSSL-Win64\bin>openssl pkcs12 -export -out C:\SSL\mysite.pfx -inkey “C:\SSL\mysite.key” -in “C:\SSL\mysite.crt” -certfile “C:\SSL\RapidSSLChain.cer” -name “mysite.com” -passout pass:Pa$$w0rd

Contents of RapidSSLChain.cer file

—–BEGIN CERTIFICATE—–
MIIDZzCCAk+gAwIBAgIQNO7aLfykR4pE94tcRe0vyDANBgkqhkiG9w0BAQUFADBG
K73RIKZaDkBOuUlRSIfgfovUFJrdwGtMWo3m4dpN7csQAjK/uixfJDVRG0nXk9pq
GXaS5/YCv5B4q4T+j5pa2f+a61ygjN1YQRoZf2CHLe7Zq89Xv90nhPM4foWdNNkr <—–Intermediate Certificate
/Esf1E6fnrItsXpIchQOmvQViis12YyUvwko2aidjVm9sML0ANiLJZSoQ9Zs/WGC
TLqwbQm6tNyFB8c=
—–END CERTIFICATE—–
—–BEGIN CERTIFICATE—–
MIIDZzCCAk+gAwIBAgIQNO7aLfykR4pE94tcRe0vyDANBgkqhkiG9w0BAQUFADBG
K73RIKZaDkBOuUlRSIfgfovUFJrdwGtMWo3m4dpN7csQAjK/uixfJDVRG0nXk9pq
GXaS5/YCv5B4q4T+j5pa2f+a61ygjN1YQRoZf2CHLe7Zq89Xv90nhPM4foWdNNkr <—–Root Certificate
/Esf1E6fnrItsXpIchQOmvQViis12YyUvwko2aidjVm9sML0ANiLJZSoQ9Zs/WGC
TLqwbQm6tNyFB8c=
—–END CERTIFICATE—–
This entry was posted in Microsoft, Scripting and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *