<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>csr &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:csr</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Tue, 14 Apr 2026 23:32:54 +0000</pubDate>
    <item>
      <title>How to properly generate a .csr file</title>
      <link>https://blogs.linux.pizza/how-to-properly-generate-a-csr-file</link>
      <description>&lt;![CDATA[During my short IT-career, I have dealt with alot people who struggle with generating a .csr file (certificate signing request) on Linux. Windows (especially IIS) have a more clearer approach so that can most of the people figure out by themselves without having to ask to many  questions :)&#xA;&#xA;The following example generates a .csr and a .key file for the Company &#34;Company Name&#34;, located in some country in the city &#34;City&#34;. Just replace the variables to your liking.&#xA;&#xA;DOMAIN=www.example.com&#xA;COUNTRY=2 letter country code&#xA;ORG=&#34;Company Name&#34;&#xA;CITY=&#34;City&#34;&#xA;STATE=&#34;State&#34;&#xA;EMAIL=&#34;youremail@example.com&#34;&#xA;&#xA;openssl req -utf8 -nameopt multiline,utf8 -new -newkey rsa:2048 -nodes -sha256 -out $DOMAIN.csr -keyout $DOMAIN.key -subj &#34;/C=${COUNTRY}/ST=${STATE}/L=${CITY}/O=${ORG}/OU=IT/CN=$DOMAIN/emailAddress=${EMAIL}&#34;&#xA;&#xA;Sometimes, you do want to generare a .csr file that includes two or more domains - a SAN certificate.&#xA;Using the same variable as above, we can now add more CN&#39;s to the .csr:&#xA;&#xA;openssl req -utf8 -nameopt multiline,utf8 -new -newkey rsa:2048 -nodes -sha256 -out $DOMAIN.csr -keyout $DOMAIN.key -subj &#34;/C=${COUNTRY}/ST=${STATE}/L=${CITY}/O=${ORG}/OU=IT/CN=$DOMAIN/emailAddress=webmaster@example.com&#34; -config &lt;(&#xA;cat &lt;&lt;-EOF&#xA;[req]&#xA;defaultbits = 2048&#xA;defaultmd = sha256&#xA;reqextensions = reqext&#xA;distinguishedname = dn&#xA;[ dn ]&#xA;[ reqext ]&#xA;subjectAltName = @altnames&#xA;[altnames]&#xA;DNS.1 = www.example.se&#xA;DNS.2 = example.se&#xA;DNS.3 = www.example.it&#xA;DNS.3 = example.it&#xA;DNS.3 = www.example.fi&#xA;DNS.3 = example.fi&#xA;DNS.3 = www.example.org&#xA;DNS.3 = example.org&#xA;EOF&#xA;)&#xA;&#xA;Lets simplify this even more, with a script!&#xA;&#xA;Running this script, will prompt you with a small dialog that ask you for the domain-name you want a .csr file for.&#xA;It creates the .key and .csr, and prints out the .csr in the termina&#xA;!/bin/bash&#xA;echo -n &#34;Please enter the full Common Name (CN)&#34;&#xA;read DOMAIN&#xA;&#xA;COUNTRY=SE&#xA;ORG=&#34;Company&#34;&#xA;CITY=&#34;City&#34;&#xA;STATE=&#34;State&#34;&#xA;EMAIL=&#34;admin@domain.tld&#34;&#xA;&#xA;openssl req -utf8 -nameopt multiline,utf8 -new -newkey rsa:2048 -nodes -sha256 -out $DOMAIN.csr -keyout $DOMAIN.key -subj &#34;/C=${COUNTRY}/ST=${STATE}/L=${CITY}/O=${ORG}/OU=IT/CN=$DOMAIN/emailAddress=$EMAIL&#34; -config &lt;(&#xA;cat &lt;&lt;-EOF&#xA;[req]&#xA;defaultbits = 2048&#xA;defaultmd = sha256&#xA;reqextensions = reqext&#xA;distinguishedname = dn&#xA;[ dn ]&#xA;[ reqext ]&#xA;subjectAltName = @altnames&#xA;[altnames]&#xA;DNS.1 = $DOMAIN&#xA;EOF&#xA;)&#xA;&#xA;echo &#34;private key and certificate request created&#34;&#xA;cat $DOMAIN.csr&#xA;exit 0 &#xA;&#xA;I hope this can prevent some headache for one or two :)&#xA;&#xA;#linux #openssl #csr #ssl #tls #certificate]]&gt;</description>
      <content:encoded><![CDATA[<p>During my short IT-career, I have dealt with alot people who struggle with generating a .csr file (certificate signing request) on Linux. Windows (especially IIS) have a more clearer approach so that can most of the people figure out by themselves without having to ask to many  questions :)</p>

<p>The following example generates a .csr and a .key file for the Company “Company Name”, located in some country in the city “City”. Just replace the variables to your liking.</p>

<pre><code>DOMAIN=www.example.com
COUNTRY=2 letter country code
ORG=&#34;Company Name&#34;
CITY=&#34;City&#34;
STATE=&#34;State&#34;
EMAIL=&#34;youremail@example.com&#34;

openssl req -utf8 -nameopt multiline,utf8 -new -newkey rsa:2048 -nodes -sha256 -out $DOMAIN.csr -keyout $DOMAIN.key -subj &#34;/C=${COUNTRY}/ST=${STATE}/L=${CITY}/O=${ORG}/OU=IT/CN=$DOMAIN/emailAddress=${EMAIL}&#34;
</code></pre>

<p>Sometimes, you do want to generare a .csr file that includes two or more domains – a SAN certificate.
Using the same variable as above, we can now add more CN&#39;s to the .csr:</p>

<pre><code>openssl req -utf8 -nameopt multiline,utf8 -new -newkey rsa:2048 -nodes -sha256 -out $DOMAIN.csr -keyout $DOMAIN.key -subj &#34;/C=${COUNTRY}/ST=${STATE}/L=${CITY}/O=${ORG}/OU=IT/CN=$DOMAIN/emailAddress=webmaster@example.com&#34; -config &lt;(
cat &lt;&lt;-EOF
[req]
default_bits = 2048
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
[ req_ext ]
subjectAltName = @alt_names
[alt_names]
DNS.1 = www.example.se
DNS.2 = example.se
DNS.3 = www.example.it
DNS.3 = example.it
DNS.3 = www.example.fi
DNS.3 = example.fi
DNS.3 = www.example.org
DNS.3 = example.org
EOF
)
</code></pre>

<h2 id="lets-simplify-this-even-more-with-a-script" id="lets-simplify-this-even-more-with-a-script">Lets simplify this even more, with a script!</h2>

<p>Running this script, will prompt you with a small dialog that ask you for the domain-name you want a .csr file for.
It creates the .key and .csr, and prints out the .csr in the termina</p>

<pre><code>#!/bin/bash
echo -n &#34;Please enter the full Common Name (CN)&#34;
read DOMAIN

COUNTRY=SE
ORG=&#34;Company&#34;
CITY=&#34;City&#34;
STATE=&#34;State&#34;
EMAIL=&#34;admin@domain.tld&#34;

openssl req -utf8 -nameopt multiline,utf8 -new -newkey rsa:2048 -nodes -sha256 -out $DOMAIN.csr -keyout $DOMAIN.key -subj &#34;/C=${COUNTRY}/ST=${STATE}/L=${CITY}/O=${ORG}/OU=IT/CN=$DOMAIN/emailAddress=$EMAIL&#34; -config &lt;(
cat &lt;&lt;-EOF
[req]
default_bits = 2048
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
[ req_ext ]
subjectAltName = @alt_names
[alt_names]
DNS.1 = $DOMAIN
EOF
)

echo &#34;private key and certificate request created&#34;
cat $DOMAIN.csr
exit 0 
</code></pre>

<p>I hope this can prevent some headache for one or two :)</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:csr" class="hashtag"><span>#</span><span class="p-category">csr</span></a> <a href="https://blogs.linux.pizza/tag:ssl" class="hashtag"><span>#</span><span class="p-category">ssl</span></a> <a href="https://blogs.linux.pizza/tag:tls" class="hashtag"><span>#</span><span class="p-category">tls</span></a> <a href="https://blogs.linux.pizza/tag:certificate" class="hashtag"><span>#</span><span class="p-category">certificate</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/how-to-properly-generate-a-csr-file</guid>
      <pubDate>Thu, 20 Jun 2019 18:17:13 +0000</pubDate>
    </item>
  </channel>
</rss>