<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Certificates &amp; TLS on Benjamin Italiaander</title><link>https://tlnd.org/topic/tls/</link><description>Recent content in Certificates &amp; TLS on Benjamin Italiaander</description><generator>Hugo</generator><language>en</language><lastBuildDate>Wed, 24 Aug 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://tlnd.org/topic/tls/index.xml" rel="self" type="application/rss+xml"/><item><title>Fetchmail OpenSSL error</title><link>https://tlnd.org/Linux/fetchmail/openSSL_and_Fetchmail_part1/</link><pubDate>Wed, 24 Aug 2022 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/fetchmail/openSSL_and_Fetchmail_part1/</guid><description>&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Old method.&lt;/strong&gt; Current fetchmail versions check the full certificate instead of an MD5 fingerprint, see &lt;a href="https://tlnd.org/Linux/fetchmail/openSSL_and_Fetchmail_part2/"&gt;part 2&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="fetchmail-openssl-reported-error"&gt;Fetchmail OpenSSL reported error&lt;/h1&gt;
&lt;p&gt;If you get an OpenSSL error with fetchmail, generate an MD5 fingerprint of the server certificate to validate the OpenSSL connection, and add it to your &lt;code&gt;~/.fetchmailrc&lt;/code&gt; file. Also make sure you have an up-to-date version of OpenSSL installed.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Generate the MD5 fingerprint&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl s_client -connect imap.example.com:993 &amp;lt;/dev/null 2&amp;gt;/dev/null &lt;span class="p"&gt;|&lt;/span&gt; openssl x509 -fingerprint -noout -md5 -in /dev/stdin
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# Add these lines, with your generated fingerprint, to your ~/.fetchmailrc file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ssl
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;sslfingerprint &lt;span class="s2"&gt;&amp;#34;01:02:03:04:05:06:07:08:09:10:11:12:13:14:15:FF&amp;#34;&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Your config should end up looking something like this:&lt;/p&gt;</description></item><item><title>Fetchmail OpenSSL error, part 2</title><link>https://tlnd.org/Linux/fetchmail/openSSL_and_Fetchmail_part2/</link><pubDate>Wed, 24 Aug 2022 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/fetchmail/openSSL_and_Fetchmail_part2/</guid><description>&lt;h1 id="fetchmail-openssl-error-part-2"&gt;Fetchmail OpenSSL error, part 2&lt;/h1&gt;
&lt;p&gt;In the past, fetchmail only required the MD5 fingerprint of an SSL certificate for validation. Since Fedora 36, fetchmail requires the complete certificate chain and &lt;code&gt;c_rehash&lt;/code&gt; links of the certificates.&lt;/p&gt;
&lt;p&gt;You can set this up with the following steps.&lt;/p&gt;
&lt;h2 id="get-the-domain-certificate"&gt;Get the domain certificate&lt;/h2&gt;
&lt;p&gt;Save the domain certificate somewhere. In this example we create a folder inside the home folder and save it there.&lt;/p&gt;
&lt;p&gt;(Replace &lt;code&gt;sub.domain.tld:993&lt;/code&gt; with your own server address, and &lt;code&gt;sub_domain_tld.cert&lt;/code&gt; with a filename that works for you.)&lt;/p&gt;</description></item><item><title>How to Set Up Your Own CA with OpenSSL</title><link>https://tlnd.org/Linux/ssl/some-instruction-aboutssl-i-found-online/</link><pubDate>Sun, 03 Jul 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssl/some-instruction-aboutssl-i-found-online/</guid><description>&lt;p&gt;I found this useful guide &lt;a href="https://gist.github.com/soarez/9688998" class="external-link" target="_blank" rel="noopener"&gt;here&lt;/a&gt;. Thank you for sharing, &lt;a href="https://uk.linkedin.com/in/soarez" class="external-link" target="_blank" rel="noopener"&gt;Igor Soarez&lt;/a&gt;!&lt;/p&gt;
&lt;h1 id="how-to-set-up-your-own-ca-with-openssl"&gt;How to set up your own CA with OpenSSL&lt;/h1&gt;
&lt;p&gt;For educational reasons I&amp;rsquo;ve decided to create my own CA.
Here is what I learned.&lt;/p&gt;
&lt;h2 id="first-things-first"&gt;First things first&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s get some context first.&lt;/p&gt;
&lt;h2 id="public-key-cryptography"&gt;Public Key Cryptography&lt;/h2&gt;
&lt;p&gt;Public key cryptography, AKA asymmetric cryptography, solves the problem of two entities communicating
securely without ever exchanging a common key, by using two related keys,
one private, one public.&lt;/p&gt;</description></item><item><title>SSL Certificate Signing Request Best Practices</title><link>https://tlnd.org/Linux/ssl/SSL-Certificate-Signing-Request-best-practices/</link><pubDate>Wed, 04 May 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssl/SSL-Certificate-Signing-Request-best-practices/</guid><description>&lt;h1 id="certificate-signing-request-best-practices-using-openssl"&gt;Certificate Signing Request Best Practices Using OpenSSL&lt;/h1&gt;
&lt;p&gt;A Certificate Signing Request (CSR) can be generated with OpenSSL. When you create a CSR, you generate two files: a private key (&lt;code&gt;.key&lt;/code&gt; file) and a certificate signing request (&lt;code&gt;.csr&lt;/code&gt; file).&lt;/p&gt;
&lt;p&gt;The best way to generate a CSR is to create a request configuration file that contains all the certificate details. In this case I call the config file &lt;code&gt;request.cnf&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt; req &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;default_bits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;4096&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;default_md&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; sha256
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; req_attributes
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;distinguished_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; req_distinguished_name
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;prompt&lt;/span&gt;		 &lt;span class="o"&gt;=&lt;/span&gt; no
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;req_extensions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; v3_req
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt; req_distinguished_name &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;countryName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; NL
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;stateOrProvinceName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; Noord-Holland
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;localityName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; Amsterdam
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;organizationName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; My company Name
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;organizationalUnitName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; IT
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;commonName&lt;/span&gt;		 &lt;span class="o"&gt;=&lt;/span&gt; *.domain.tld
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;emailAddress&lt;/span&gt;		 &lt;span class="o"&gt;=&lt;/span&gt; admin@domain.tld
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;v3_req&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;subjectKeyIdentifier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;hash&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;basicConstraints&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; critical, CA:false
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;keyUsage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; digitalSignature, keyEncipherment
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;extendedKeyUsage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; serverAuth
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;subjectAltName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; @alt_names
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt; req_attributes &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt; req_ext &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nv"&gt;subjectAltName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; @alt_names
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;[&lt;/span&gt;alt_names&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DNS.1 &lt;span class="o"&gt;=&lt;/span&gt; domain.tld
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;DNS.2 &lt;span class="o"&gt;=&lt;/span&gt; *.domain.tld
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After creating this config file, you can generate the key and the CSR. Make sure you never share the &lt;code&gt;.key&lt;/code&gt; file: it is your private key.&lt;/p&gt;</description></item><item><title>Extract the Public Key from a Private Key with OpenSSL</title><link>https://tlnd.org/Linux/ssl/extract-publickey-from-privatekey-openssl/</link><pubDate>Fri, 15 Apr 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssl/extract-publickey-from-privatekey-openssl/</guid><description>&lt;h1 id="extract-the-rsa-public-key-from-a-private-key"&gt;Extract the RSA public key from a private key&lt;/h1&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# write the public key to a file (works for RSA, EC and Ed25519 keys)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl pkey -in domain.tld.key -pubout -out domain.tld.pubkey
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# show the public key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl pkey -in domain.tld.pubkey -pubin -noout -text
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# the same with the RSA-only command&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl rsa -in domain.tld.key -pubout -out domain.tld.pubkey
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>SSL Rehash and File Permissions</title><link>https://tlnd.org/Linux/ssl/ssl-rehash-and-filepermissions/</link><pubDate>Sun, 06 Mar 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssl/ssl-rehash-and-filepermissions/</guid><description>&lt;h1 id="rehash-certificates-and-set-file-permissions"&gt;Rehash certificates and set file permissions&lt;/h1&gt;
&lt;p&gt;A script I use in a certificate folder. It:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;creates the OpenSSL hash links (&lt;code&gt;&amp;lt;hash&amp;gt;.0&lt;/code&gt;) for the CA bundle and the certificate bundles,&lt;/li&gt;
&lt;li&gt;builds &lt;code&gt;ssl-bundle.crt&lt;/code&gt; (certificate + CA bundle),&lt;/li&gt;
&lt;li&gt;makes certificates read-only (&lt;code&gt;0444&lt;/code&gt;) and keys readable by the owner only (&lt;code&gt;0400&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;gives the files to the web server user (default &lt;code&gt;nginx&lt;/code&gt;, or the user/group you pass as arguments).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Run it inside the certificate folder: &lt;code&gt;./rehash.sh [user] [group]&lt;/code&gt;&lt;/p&gt;</description></item><item><title>SSL Checks</title><link>https://tlnd.org/Linux/ssl/ssl-checks/</link><pubDate>Mon, 08 Feb 2016 00:00:00 +0000</pubDate><guid>https://tlnd.org/Linux/ssl/ssl-checks/</guid><description>&lt;h2 id="regular-ssl-checks"&gt;Regular SSL checks&lt;/h2&gt;
&lt;p&gt;Check a Certificate Signing Request (CSR)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl req -text -noout -verify -in CSR.csr
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check a private key&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl rsa -in privateKey.key -check
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check a certificate&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl x509 -in certificate.crt -text -noout
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check a PKCS#12 file (.pfx or .p12)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;openssl pkcs12 -info -in keyStore.p12
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="check-whether-a-certificate-and-key-are-a-pair"&gt;Check whether a certificate and key are a pair&lt;/h2&gt;
&lt;p&gt;You can check whether a &lt;code&gt;.crt&lt;/code&gt; and a &lt;code&gt;.key&lt;/code&gt; file match by comparing an MD5 hash of their modulus. If both outputs are the same, you have a matching pair.&lt;/p&gt;</description></item></channel></rss>