<div dir="ltr">Hello!<div><br></div><div>I've been stuck debugging OpenLDAP + GnuTLS and OpenSSL certificates (I really didn't want to rewrite my certificate generation) as suggested by the wiki here: <a href="https://wiki.debian.org/LDAP/OpenLDAPSetup">https://wiki.debian.org/LDAP/OpenLDAPSetup</a> (at symptoms round 2).</div>
<div>It turns out that clients try to connect to OpenLDAP (both openssl and gnutls clients) using TLS1.2 which judging by this output, the server does not support properly:</div><div><div><font face="courier new, monospace" color="#666666"># gnutls-cli-debug ldap -p 636</font></div>
<div><font face="courier new, monospace" color="#666666">Resolving 'ldap'...</font></div><div><font face="courier new, monospace" color="#666666">Connecting to '10.146.12.158:636'...</font></div><div><font face="courier new, monospace" color="#666666">Checking for SSL 3.0 support... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking whether %COMPAT is required... no</font></div><div><font face="courier new, monospace" color="#666666">Checking for TLS 1.0 support... yes</font></div><div>
<font face="courier new, monospace" color="#666666">Checking for TLS 1.1 support... yes</font></div><div><font face="courier new, monospace" color="#666666">Checking fallback from TLS 1.1 to... N/A</font></div><div><font face="courier new, monospace" color="#666666">Checking for TLS 1.2 support... no</font></div>
<div><font face="courier new, monospace" color="#666666">Checking whether we need to disable TLS 1.0... N/A</font></div><div><font face="courier new, monospace" color="#666666">Checking for Safe renegotiation support... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking for Safe renegotiation support (SCSV)... yes</font></div><div><font face="courier new, monospace" color="#666666">Checking for HTTPS server name... not checked</font></div>
<div><font face="courier new, monospace" color="#666666">Checking for version rollback bug in RSA PMS... no</font></div><div><font face="courier new, monospace" color="#666666">Checking for version rollback bug in Client Hello... no</font></div>
<div><font face="courier new, monospace" color="#666666">Checking whether the server ignores the RSA PMS version... no</font></div><div><font face="courier new, monospace" color="#666666">Checking whether the server can accept Hello Extensions... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking whether the server can accept cipher suites not in SSL 3.0 spec... yes</font></div><div><font face="courier new, monospace" color="#666666">Checking whether the server can accept a bogus TLS record version in the client hello... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking for certificate information... N/A</font></div><div><font face="courier new, monospace" color="#666666">Checking for trusted CAs... N/A</font></div><div><font face="courier new, monospace" color="#666666">Checking whether the server understands TLS closure alerts... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking whether the server supports session resumption... no</font></div><div><font face="courier new, monospace" color="#666666">Checking for export-grade ciphersuite support... no</font></div>
<div><font face="courier new, monospace" color="#666666">Checking RSA-export ciphersuite info... N/A</font></div><div><font face="courier new, monospace" color="#666666">Checking for anonymous authentication support... no</font></div>
<div><font face="courier new, monospace" color="#666666">Checking anonymous Diffie-Hellman group info... N/A</font></div><div><font face="courier new, monospace" color="#666666">Checking for ephemeral Diffie-Hellman support... no</font></div>
<div><font face="courier new, monospace" color="#666666">Checking ephemeral Diffie-Hellman group info... N/A</font></div><div><font face="courier new, monospace" color="#666666">Checking for AES cipher support (TLS extension)... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking for CAMELLIA cipher support (TLS extension)... yes</font></div><div><font face="courier new, monospace" color="#666666">Checking for 3DES cipher support... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking for ARCFOUR 128 cipher support... yes</font></div><div><font face="courier new, monospace" color="#666666">Checking for ARCFOUR 40 cipher support... no</font></div>
<div><font face="courier new, monospace" color="#666666">Checking for MD5 MAC support... yes</font></div><div><font face="courier new, monospace" color="#666666">Checking for SHA1 MAC support... yes</font></div><div><font face="courier new, monospace" color="#666666">Checking for max record size (TLS extension)... yes</font></div>
<div><font face="courier new, monospace" color="#666666">Checking for OpenPGP authentication support (TLS extension)... no</font></div></div><div><br></div><div>Clients still try to connect with TLS1.2 to the server, but you get this error message when you try:<br>
<div><font face="courier new, monospace" color="#444444"># gnutls-cli -d 4 -p 636 ldap</font></div><div><font face="courier new, monospace" color="#444444">Resolving 'ldap'...</font></div><div><font face="courier new, monospace" color="#444444">Connecting to '10.146.12.158:636'...</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Allocating epoch #0</font></div><div><font face="courier new, monospace" color="#444444">|<2>| ASSERT: gnutls_constate.c:695</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Allocating epoch #1</font></div><div><font face="courier new, monospace" color="#444444">|<3>| HSK[0xe39500]: Keeping ciphersuite: RSA_AES_256_CBC_SHA1</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[0xe39500]: Sending extension SERVER NAME (20 bytes)</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[0xe39500]: Sending extension SAFE RENEGOTIATION (1 bytes)</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[0xe39500]: Sending extension SESSION TICKET (0 bytes)</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (4.2) DSA-SHA256</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (4.1) RSA-SHA256</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (2.1) RSA-SHA1</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (2.2) DSA-SHA1</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[0xe39500]: Sending extension SIGNATURE ALGORITHMS (10 bytes)</font></div>
<div><font face="courier new, monospace" color="#444444">|<3>| HSK[0xe39500]: CLIENT HELLO was sent [94 bytes]</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Sending Packet[0] Handshake(22) with length: 94</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Sent Packet[1] Handshake(22) with length: 99</font></div><div><font face="courier new, monospace" color="#444444">|<2>| ASSERT: gnutls_buffers.c:640</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| ASSERT: gnutls_record.c:969</font></div><div><font face="courier new, monospace" color="#444444">|<2>| ASSERT: gnutls_handshake.c:2762</font></div>
<div><font face="courier new, monospace" color="#444444">*** Fatal error: A TLS packet with unexpected length was received.</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC: Sending Alert[2|22] - Record overflow</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Sending Packet[1] Alert(21) with length: 2</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Sent Packet[2] Alert(21) with length: 7</font></div>
<div><font face="courier new, monospace" color="#444444">*** Handshake has failed</font></div><div><font face="courier new, monospace" color="#444444">GnuTLS error: A TLS packet with unexpected length was received.</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Epoch #0 freed</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0xe39500]: Epoch #1 freed</font></div>
</div><div><br></div><div>I might also add that the TLSCipherSuite directive documentation is horrible. I spent well over an hour trying to find a cipher suite string that worked at all (setting an invalid one in cn=config crashes the server).</div>
<div>I found some correspondence here:</div><div><a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541256">http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541256</a><br></div><div>That helped me find a cipher suite string that actually made my clients able to connect at all: "+RSA:+AES-256-CBC:+SHA1:-VERS-TLS1.2". This is the minimal string that makes both openssl and gnutls clients able to connect without specifying a cipher list themselves.</div>
<div>I've tried using more general olcTLSCipherSuite definitions, including only "-VERS-TLS1.2", but it seems that it does nothing and definitions like: "+KX-ALL:+CIPHER-ALL:+MAC-ALL:-VERS-TLS1.2" seems to break the server like any unsupported string would.</div>
<div><a href="http://gnutls.org/manual/html_node/Priority-Strings.html">http://gnutls.org/manual/html_node/Priority-Strings.html</a> has helped me some, but I haven't managed to use it to build a more general TLSCipherSuite string that wouldn't just be listing all of them, but you can't do that either, because you get an error like this:<br>
</div><div><div>ldap_modify: Invalid syntax (21)</div><div> additional info: olcTLSCipherSuite: value #0 invalid per syntax</div></div><div><br></div><div>This a snippet from the handshake output from a successful connect using gnutls-cli:</div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[0x1ab7500]: Sending extension SERVER NAME (20 bytes)<br></font></div><div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[0x1ab7500]: Sending extension SAFE RENEGOTIATION (1 bytes)</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[0x1ab7500]: Sending extension SESSION TICKET (0 bytes)</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (4.2) DSA-SHA256</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (4.1) RSA-SHA256</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (2.1) RSA-SHA1</font></div>
<div><font face="courier new, monospace" color="#444444">|<2>| EXT[SIGA]: sent signature algo (2.2) DSA-SHA1</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[0x1ab7500]: Sending extension SIGNATURE ALGORITHMS (10 bytes)</font></div>
<div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: CLIENT HELLO was sent [140 bytes]</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Sending Packet[0] Handshake(22) with length: 140</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Sent Packet[1] Handshake(22) with length: 145</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Expected Packet[0] Handshake(22) with length: 1</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Received Packet[0] Handshake(22) with length: 81</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Decrypted Packet[0] Handshake(22) with length: 81</font></div>
<div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: SERVER HELLO was received [81 bytes]</font></div><div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: Server's version: 3.2</font></div>
<div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: SessionID length: 32</font></div><div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: SessionID: 256659f9e27a593ca972a30157531673468d82f1cb65532121b503c09cfb6944</font></div>
<div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: Selected cipher suite: RSA_AES_256_CBC_SHA1</font></div><div><font face="courier new, monospace" color="#444444">|<2>| EXT[0x1ab7500]: Parsing extension 'SAFE RENEGOTIATION/65281' (1 bytes)</font></div>
<div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: Safe renegotiation succeeded</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Expected Packet[1] Handshake(22) with length: 1</font></div>
<div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Received Packet[1] Handshake(22) with length: 6614</font></div><div><font face="courier new, monospace" color="#444444">|<4>| REC[0x1ab7500]: Decrypted Packet[1] Handshake(22) with length: 6614</font></div>
<div><font face="courier new, monospace" color="#444444">|<3>| HSK[0x1ab7500]: CERTIFICATE was received [6614 bytes]</font></div></div><div><br></div><div>It seems to be expecting handshake packets with a size of 1 byte, but maybe that isn't a blocking violation in TLS1.1 and earlier?</div>
<div>Well, I feel like I'm out of my depth here in any case and I'm hoping that you might at the very least be able to point me in the right direction of where to file an issue for this since I'm not sure if it is related to GnuTLS, OpenSSL, OpenLDAP, or the packaging of OpenLDAP+GnuTLS.</div>
<div><br></div><div>Best regards,</div><div>Mikael Knutsson</div></div>