<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Key on Humberto Rocha</title><link>https://humberto.io/tags/key/</link><description>Recent content in Key on Humberto Rocha</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 10 Jul 2023 17:35:05 -0400</lastBuildDate><atom:link href="https://humberto.io/tags/key/index.xml" rel="self" type="application/rss+xml"/><item><title>Extract certificate and key from .pfx file</title><link>https://humberto.io/bits/extract-certificate-and-key-from-pfx-file/</link><pubDate>Mon, 10 Jul 2023 00:00:00 +0000</pubDate><guid>https://humberto.io/bits/extract-certificate-and-key-from-pfx-file/</guid><description>&lt;p>Extract the certificate from the &lt;code>.pfx&lt;/code> file:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>openssl pkcs12 -in &amp;lt;DOT_PFX_FILE&amp;gt; -clcerts -nokeys -chain -out certificate.crt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Extract the private key in &lt;code>.pem&lt;/code> format without encryption from the &lt;code>.pfx&lt;/code> file:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>openssl pkcs12 -in &amp;lt;DOT_PFX_FILE&amp;gt; -nocerts -nodes -out private_key.pem
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Convert the &lt;code>.pem&lt;/code> into &lt;code>RSA&lt;/code> key format:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#cdd6f4;background-color:#1e1e2e;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>openssl rsa -in private_key.pem -out id_rsa
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>If you are using OpenSSL 3 it will default it&amp;rsquo;s output to be in &lt;code>PKCS8&lt;/code> format, that contains encapsulation boundaries like this:&lt;/p></description></item></channel></rss>