ssl

Get and check the certificate of a domain

Launch the following command:

$ openssl s_cient -connect www.domain.tld

To force the SNI:

$ openssl s_cient -connect www.domain.tld -servername www.domain.tld 

Display a certificate

$ openssl x509 -in certificate.crt -text -noout
<div class="highlight"><pre style="background-color:#eed;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash"><span style="color:#228b22"># Check the modulus</span>

The modulus is an element found in the CSR, the private key and the certificate. <span style="color:#cd5555">\
</span><span style="color:#cd5555"></span>It is always the same: so it is really useful when you need to prove that a certificate has not been generated from 
a CSR.

&lt;div <span style="color:#00688b">class</span>=<span style="color:#cd5555">&#34;highlight&#34;</span>&gt;&lt;pre <span style="color:#00688b">style</span>=<span style="color:#cd5555">&#34;background-color:#eed;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;</span>&gt;&lt;code <span style="color:#00688b">class</span>=<span style="color:#cd5555">&#34;language-bash&#34;</span> data-lang=<span style="color:#cd5555">&#34;bash&#34;</span>&gt;openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl req -noout -modulus -in CSR.csr | openssl md5
&amp;lt;div &lt;span <span style="color:#00688b">style</span>=<span style="color:#cd5555">&#34;color:#00688b&#34;</span>&gt;class&lt;/span&gt;=&lt;span <span style="color:#00688b">style</span>=<span style="color:#cd5555">&#34;color:#cd5555&#34;</span>&gt;&amp;<span style="color:#228b22">#34;highlight&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;pre &lt;span style=&#34;color:#00688b&#34;&gt;style&lt;/span&gt;=&lt;span style=&#34;color:#cd5555&#34;&gt;&amp;#34;background-color:#eed;-moz-tab-size:4;-o-tab-size:4;tab-size:4&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;code &lt;span style=&#34;color:#00688b&#34;&gt;class&lt;/span&gt;=&lt;span style=&#34;color:#cd5555&#34;&gt;&amp;#34;language-bash&amp;#34;&lt;/span&gt; data-lang=&lt;span style=&#34;color:#cd5555&#34;&gt;&amp;#34;bash&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</span></code></pre></div>