<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>pki &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:pki</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Tue, 21 Apr 2026 12:51:57 +0000</pubDate>
    <item>
      <title>Secure your API with Client-certificate authenatication in NGINX</title>
      <link>https://blogs.linux.pizza/secure-your-api-with-client-certificate-authenatication-in-nginx</link>
      <description>&lt;![CDATA[After a few hours trying to make it work with my current CA, where the Root is stored offline, AIA, OCSP, CRL and all that stuff is done by the book - I gave up.&#xA;Somehow, the Open Source variant of Nginx does not really like my OCSP setup, no idea why and I have no idea how to troubleshoot that.&#xA;&#xA;Solution? KISS-principle!&#xA;&#xA;I&#39;ll write this down, quick and dirty. But hopefully it helps someone.&#xA;&#xA;Lets start with create the private key for the CA that we will create:&#xA;&#xA;openssl genpkey -algorithm RSA -out CAROOT.key -aes256&#xA;With this command, we have created a private key with AES256. You will be prompted to give a password - write that down.&#xA;And the following command will create a certificate from the private key, valid for 10 years.&#xA;&#xA;openssl req -x509 -new -nodes -key CAROOT.key -sha256 -days 3650 -out CAROOT.crt&#xA;Fill in the information that the above command wants of you, like country-code, and so on.&#xA;After that, your CA is done. The crude, ugly and honestly boring CA. But it&#39;ll work for this usecase.&#xA;&#xA;Let&#39;s create the client-certificate!&#xA;&#xA;First, will start by creating the private.key, and the .csr:&#xA;openssl genpkey -algorithm RSA -out client-cert.key&#xA;openssl req -new -key client.key -out client-cert.csr&#xA;And again, fill out the information wanted by openssl that will populate the .csr. Make it looks pretty.&#xA;Ideally, the commands shall be run on the client only, so the private-key never leaves the client. The .csr is what the CA will need to sign and create a valid certificate.&#xA;&#xA;Bring the .csr to the CA, and sign it:&#xA;&#xA;openssl x509 -req -in client-cert.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client-cert.crt -days 365 -sha256&#xA;This will give you a signed certificate for your client named &#34;client-cert.crt&#34; - you may bring that to the client-machine and install it.&#xA;&#xA;Firefox wants a .pfx:&#xA;&#xA;In order to import the certificate into Firefox, you&#39;ll need to convert it to p12/pfx format:&#xA;openssl pkcs12 -export -out client-cert.pfx -inkey client-cert.key -in client-cert.crt -certfile CAROOT.crt&#xA;Please note, that you&#39;ll need the CAROOT.crt file too that you created.&#xA;&#xA;Configure NGINX to do client-certificate authentication&#xA;&#xA;Navigate to the virtualhost you want to enable client-certificate authentication on, and add the following:&#xA;&#xA;    sslclientcertificate /etc/ssl/private/CAROOT.crt;&#xA;    sslverifyclient on;&#xA;    sslverifydepth 2;&#xA;Please note, that you have to place the CA_ROOT.crt file in &#xA;Restart NGINX and try to visit the site. You&#39;ll probably be asked for permission to use client-certificate authentication.&#xA;&#xA;#linux #openssl #nginx #pki&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>After a few hours trying to make it work with my current CA, where the Root is stored offline, AIA, OCSP, CRL and all that stuff is done by the book – I gave up.
Somehow, the Open Source variant of Nginx does not really like my OCSP setup, no idea why and I have no idea how to troubleshoot that.</p>

<h4 id="solution-kiss-principle" id="solution-kiss-principle">Solution? KISS-principle!</h4>

<p>I&#39;ll write this down, quick and dirty. But hopefully it helps someone.</p>

<p>Lets start with create the private key for the CA that we will create:</p>

<pre><code>openssl genpkey -algorithm RSA -out CA_ROOT.key -aes256
</code></pre>

<p>With this command, we have created a private key with AES256. You will be prompted to give a password – write that down.
And the following command will create a certificate from the private key, valid for 10 years.</p>

<pre><code>openssl req -x509 -new -nodes -key CA_ROOT.key -sha256 -days 3650 -out CA_ROOT.crt
</code></pre>

<p>Fill in the information that the above command wants of you, like country-code, and so on.
After that, your CA is done. The crude, ugly and honestly boring CA. But it&#39;ll work for this usecase.</p>

<h4 id="let-s-create-the-client-certificate" id="let-s-create-the-client-certificate">Let&#39;s create the client-certificate!</h4>

<p>First, will start by creating the private.key, and the .csr:</p>

<pre><code>openssl genpkey -algorithm RSA -out client-cert.key
openssl req -new -key client.key -out client-cert.csr
</code></pre>

<p>And again, fill out the information wanted by openssl that will populate the .csr. Make it looks pretty.
Ideally, the commands shall be run on the client only, so the private-key never leaves the client. The .csr is what the CA will need to sign and create a valid certificate.</p>

<p>Bring the .csr to the CA, and sign it:</p>

<pre><code>openssl x509 -req -in client-cert.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client-cert.crt -days 365 -sha256
</code></pre>

<p>This will give you a signed certificate for your client named “client-cert.crt” – you may bring that to the client-machine and install it.</p>

<h4 id="firefox-wants-a-pfx" id="firefox-wants-a-pfx">Firefox wants a .pfx:</h4>

<p>In order to import the certificate into Firefox, you&#39;ll need to convert it to p12/pfx format:</p>

<pre><code>openssl pkcs12 -export -out client-cert.pfx -inkey client-cert.key -in client-cert.crt -certfile CA_ROOT.crt
</code></pre>

<p>Please note, that you&#39;ll need the CA_ROOT.crt file too that you created.</p>

<h4 id="configure-nginx-to-do-client-certificate-authentication" id="configure-nginx-to-do-client-certificate-authentication">Configure NGINX to do client-certificate authentication</h4>

<p>Navigate to the virtualhost you want to enable client-certificate authentication on, and add the following:</p>

<pre><code>    ssl_client_certificate /etc/ssl/private/CA_ROOT.crt;
    ssl_verify_client on;
    ssl_verify_depth 2;
</code></pre>

<p>Please note, that you have to place the CA_ROOT.crt file in <code>/etc/ssl/private/</code></p>

<p>Restart NGINX and try to visit the site. You&#39;ll probably be asked for permission to use client-certificate authentication.</p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:openssl" class="hashtag"><span>#</span><span class="p-category">openssl</span></a> <a href="https://blogs.linux.pizza/tag:nginx" class="hashtag"><span>#</span><span class="p-category">nginx</span></a> <a href="https://blogs.linux.pizza/tag:pki" class="hashtag"><span>#</span><span class="p-category">pki</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/secure-your-api-with-client-certificate-authenatication-in-nginx</guid>
      <pubDate>Sat, 15 Nov 2025 20:32:09 +0000</pubDate>
    </item>
    <item>
      <title>Replace the default certificate on a Unifi Dream Router with your own</title>
      <link>https://blogs.linux.pizza/replace-the-default-certificate-on-a-unifi-dream-router-with-your-own</link>
      <description>&lt;![CDATA[I dont claim responsibility for anything being done on your router. This short TODO is written for myself - dont follow if you are not familiar with certificates and PKI.&#xA;&#xA;1  SSH into your machine&#xA;Navigate to Replace Replace Restart  Unifi Core:&#xA;systemctl restart unifi-core&#xA;&#xA;Done!&#xA;A screenshot, showing a valid certificate on udr.selea.se, located on a Unifi Dream Router&#xA;&#xA;#linux #pki #certificates #unifi]]&gt;</description>
      <content:encoded><![CDATA[<h3 id="i-dont-claim-responsibility-for-anything-being-done-on-your-router-this-short-todo-is-written-for-myself-dont-follow-if-you-are-not-familiar-with-certificates-and-pki" id="i-dont-claim-responsibility-for-anything-being-done-on-your-router-this-short-todo-is-written-for-myself-dont-follow-if-you-are-not-familiar-with-certificates-and-pki">I dont claim responsibility for anything being done on your router. This short TODO is written for myself – dont follow if you are not familiar with certificates and PKI.</h3>

<p>1  SSH into your machine
2. Navigate to <code>/data/unifi-core/config</code>
3. Replace <code>unifi-core.key</code> with your private key
4. Replace <code>unifi-core.crt</code> with your TLS-certificate
5. Restart  Unifi Core:</p>

<pre><code>systemctl restart unifi-core
</code></pre>

<p>Done!
<img src="https://pictures.blogs.linux.pizza/misc/udr.png" alt="A screenshot, showing a valid certificate on udr.selea.se, located on a Unifi Dream Router" title="UDR certificate"></p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:pki" class="hashtag"><span>#</span><span class="p-category">pki</span></a> <a href="https://blogs.linux.pizza/tag:certificates" class="hashtag"><span>#</span><span class="p-category">certificates</span></a> <a href="https://blogs.linux.pizza/tag:unifi" class="hashtag"><span>#</span><span class="p-category">unifi</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/replace-the-default-certificate-on-a-unifi-dream-router-with-your-own</guid>
      <pubDate>Sun, 24 Mar 2024 15:51:35 +0000</pubDate>
    </item>
  </channel>
</rss>