<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Passing Curiosity: Posts tagged gnutls</title>
    <link href="https://passingcuriosity.com/tags/gnutls/gnutls.xml" rel="self" />
    <link href="https://passingcuriosity.com" />
    <id>https://passingcuriosity.com/tags/gnutls/gnutls.xml</id>
    <author>
        <name>Thomas Sutton</name>
        
        <email>me@thomas-sutton.id.au</email>
        
    </author>
    <updated>2021-03-30T00:00:00Z</updated>
    <entry>
    <title>Reducing TLS client security requirements on OpenSSL and GnuTLS</title>
    <link href="https://passingcuriosity.com/2021/diffie-hellman-short-primes-disable/" />
    <id>https://passingcuriosity.com/2021/diffie-hellman-short-primes-disable/</id>
    <published>2021-03-30T00:00:00Z</published>
    <updated>2021-03-30T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p>Most operating systems do a pretty OK job of shipping libraries that have
relatively secure configurations. Unfortunately, lots of organisations –
especially large organisations – do a terrible job of building secure
networks for them to run in. After “security” “appliances”, TLS is one thing
that sticks out as regularly screwed up.</p>
<p>In my current organisation we must interact with a number of servers with,
by modern standards, insecure TLS configuration. In particular, Diffie-Hellman
parameters that are too short to be considered secure. OpenSSL and GnuTLS as
shipped in Ubuntu 20.04 both refuse to handshake with these services. Well
done!</p>
<p>Unfortunately, it’s a large organisation so there is absolutely no chance of
getting these server configurations updated. So we need to reconfigure our
TLS client libraries to accept the low-security servers.</p>
<p>First, a disclaimer: I am not a cryptographer, security engineer, encryption
library developer, informed amateur, or even a particularly observant
bystander. You should be accepting security advice from me.</p>
<h2 id="gnutls">GnuTLS</h2>
<p>A great deal of GnuTLS operation is configured using a priority string. In
the version I’m looking at, the default priority string is</p>
<pre><code>NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2:+VERS-DTLS1.2:%PROFILE_MEDIUM</code></pre>
<p>It’s the <code>%PROFILE_MEDIUM</code> that does things like set the minimum lengths
for keys, DH primes, etc. You can find the various security profile options
in the GnuTLS manual at <a href="https://www.gnutls.org/manual/html_node/Selecting-cryptographic-key-sizes.html">Section 6.11 Selecting cryptographic key sizes</a>.
My current project needs to support servers using Diffie-Hellman primes of
1024 bits, so I need to use <code>PROFILE_LOW</code>.</p>
<p>You can override the default priority string by editing (or creating)
<code>/etc/gnutls/config</code> like so:</p>
<pre><code>[overrides]
default-priority-string = NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2:+VERS-DTLS1.2:%PROFILE_LOW</code></pre>
<p>This should then apply to any application that doesn’t specify it’s own
priority string.</p>
<h2 id="openssl">OpenSSL</h2>
<p>Updating the OpenSSL configuration is a <em>much</em> more complicated proposition.
The configuration used by applications is stored in a section named by the
<code>openssl_conf</code> variable. This is <em>not</em> in a section, so it’ll be at the top
of the file if it’s set. In my experience, it often isn’t set.</p>
<p>If it is set, go find the section it names, then follow <code>ssl_conf</code> to the
section containing the SSL configuration, then follow <code>system_default</code> to
the section <em>it</em> names.</p>
<p>Here, you can specify something like:</p>
<pre><code>CipherString = DEFAULT:@SECLEVEL=1</code></pre>
<p>If all that isn’t already in your <code>openssl.cnf</code>, you need to create a new
section, which points to a section, which points to a section. This can all
go at the end of the file. Then you need to add a variable <em>not</em> in a section
that points to the first of those sections.</p>
<p>Here’s a shell script that does just that:</p>
<pre><code>#!/bin/sh
# Update the OpenSSL configuration to use lower default security level. This
# allows us to connect to TLS servers using insecure certificates issued by the
# internal CA.

set -eux

mv /etc/ssl/openssl.cnf /etc/ssl/openssl.cnf.orig

{
cat &lt;&lt;EOF
# Override the default OpenSSL configuration with less secure settings that
# allow communication with the many services that use insecure certificates
# issued by the internal CA.
openssl_conf = default_conf
EOF

cat /etc/ssl/openssl.cnf.orig;

cat &lt;&lt;EOF
# Default configuration for applications which use OpenSSL.
[ default_conf ]
ssl_conf = ssl_sect

[ ssl_sect ]
system_default = system_default_sect

[ system_default_sect ]
MinProtocol = TLSv1.2
# Be less secure when negotiating ciphers, verifying certificates, etc.
CipherString = DEFAULT:@SECLEVEL=1
EOF
} &gt; /etc/ssl/openssl.cnf</code></pre>
<p>It’s probably a bit too lax but I use it in Docker images based on
<code>ubuntu:20.04</code> and it seems to do the trick.</p>]]></summary>
</entry>

</feed>
