Bonjour,
J'ai suivi la création du certificat depuis la page d'openldap (ici: http://www.openldap.org/faq/data/cache/185.html )
J'ai aussi générer un certificat cacert et j'obtient le même résultat.
Lorsque je fais un
root@DB:/etc/ldap# ldapsearch -ZZ
    ldap_start_tls: Protocol error (2)
            additional info: unsupported extended operationalors qu'un :
root@DB:~# ldapsearch
    SASL/EXTERNAL authentication started
    SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
    SASL SSF: 0
    # extended LDIF
    #
    # LDAPv3
    # base <> (default) with scope subtree
    # filter: (objectclass=*)
    # requesting: ALL
    #
    # search result
    search: 2
    result: 32 No such object
    # numResponses: 1Quelques logs additionnel :
root@DB:~# netstat -tan
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State
    tcp        0      0 0.0.0.0:636             0.0.0.0:*               LISTEN
    tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN
    tcp6       0      0 :::636                  :::*                    LISTEN
    tcp6       0      0 :::389                  :::*                    LISTENroot@DB:~# cgrep /etc/default/slapd
    SLAPD_CONF=
    SLAPD_USER="openldap"
    SLAPD_GROUP="openldap"
    SLAPD_PIDFILE=
    SLAPD_SERVICES="ldap:/// ldaps:/// ldapi:///"
    SLAPD_SENTINEL_FILE=/etc/ldap/noslapd
    SLAPD_OPTIONS=""root@DB:/etc/ldap# l
    total 48K
    -rw-r--r-- 1 root     root     4.4K Sep 10 17:20 cacert.pem
    drwxr-xr-x 2 root     root     4.0K Sep 10 17:19 cert_old
    -rw-r--r-- 1 root     root        0 Sep 10 17:17 db_crt.pem
    -rw------- 1 root     root     2.7K Sep 10 17:17 db_key.pem
    -rw-r--r-- 1 root     root      183 Sep  4 15:49 init.ldif
    -rw-r--r-- 1 root     root      178 Sep  4 16:14 olcAccess.ldif
    -rw-r--r-- 1 root     root      463 Sep  4 16:12 olcDbIndex.ldif
    -rw-r--r-- 1 root     root      250 Sep  4 17:16 olcSSL.ldif
    drwxr-xr-x 2 root     root     4.0K Apr 23  2013 sasl2
    drwxr-xr-x 2 root     root     4.0K Sep  4 15:27 schema
    drwxr-xr-x 3 openldap openldap 4.0K Sep  5 16:33 slapd.d
    -rw-r--r-- 1 root     root       88 Sep  4 15:50 ssl.ldifPremier signe d'erreur, mais que je n'arrive pas à comprendre/debugger :
root@DB:/etc/ldap# openssl s_client -connect db.m0le.net:389 -state -showcerts -CAfile /etc/ldap/cacert.pem
    CONNECTED(00000003)
    SSL_connect:before/connect initialization
    SSL_connect:unknown state
    139821511227048:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177:
    ---
    no peer certificate available
    ---
    No client certificate CA names sent
    ---
    SSL handshake has read 0 bytes and written 308 bytes
    ---
    New, (NONE), Cipher is (NONE)
    Secure Renegotiation IS NOT supported
    Compression: NONE
    Expansion: NONE
    ---root@DB:/etc/ldap/cert_old# gnutls-cli --x509cafile /etc/ldap/cacert.pem --x509keyfile /etc/ldap/db_key.pem --x509certfile /etc/ldap/db_crt.pem -d 5 -p 636 db.m0le.net
    Processed 1 CA certificate(s).
    Processed 1 client certificates...
    |<2>| ASSERT: x509_b64.c:453
    |<2>| Could not find '-----BEGIN RSA PRIVATE KEY'
    |<2>| ASSERT: x509_b64.c:453
    |<2>| Could not find '-----BEGIN DSA PRIVATE KEY'
    |<2>| ASSERT: privkey.c:387
    |<2>| Falling back to PKCS #8 key decoding
    Processed 1 client X.509 certificates...
    Resolving 'db.m0le.net'...
    Connecting to '10.0.0.4:636'...
    |<4>| REC[0xc65a70]: Allocating epoch #0
    |<2>| ASSERT: gnutls_constate.c:695
    |<4>| REC[0xc65a70]: Allocating epoch #1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_RSA_AES_128_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_RSA_AES_128_CBC_SHA256
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_RSA_CAMELLIA_128_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_RSA_AES_256_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_RSA_AES_256_CBC_SHA256
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_RSA_CAMELLIA_256_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_RSA_3DES_EDE_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_DSS_AES_128_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_DSS_AES_128_CBC_SHA256
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_DSS_CAMELLIA_256_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_DSS_3DES_EDE_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: DHE_DSS_ARCFOUR_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_AES_128_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_AES_128_CBC_SHA256
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_CAMELLIA_128_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_AES_256_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_AES_256_CBC_SHA256
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_CAMELLIA_256_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_3DES_EDE_CBC_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_ARCFOUR_SHA1
    |<3>| HSK[0xc65a70]: Keeping ciphersuite: RSA_ARCFOUR_MD5
    |<2>| EXT[0xc65a70]: Sending extension SERVER NAME (16 bytes)
    |<2>| EXT[0xc65a70]: Sending extension SAFE RENEGOTIATION (1 bytes)
    |<2>| EXT[0xc65a70]: Sending extension SESSION TICKET (0 bytes)
    |<2>| EXT[SIGA]: sent signature algo (4.2) DSA-SHA256
    |<2>| EXT[SIGA]: sent signature algo (4.1) RSA-SHA256
    |<2>| EXT[SIGA]: sent signature algo (2.1) RSA-SHA1
    |<2>| EXT[SIGA]: sent signature algo (2.2) DSA-SHA1
    |<2>| EXT[0xc65a70]: Sending extension SIGNATURE ALGORITHMS (10 bytes)
    |<3>| HSK[0xc65a70]: CLIENT HELLO was sent [136 bytes]
    |<4>| REC[0xc65a70]: Sending Packet[0] Handshake(22) with length: 136
    |<4>| REC[0xc65a70]: Sent Packet[1] Handshake(22) with length: 141
    |<2>| ASSERT: gnutls_buffers.c:640
    |<2>| ASSERT: gnutls_record.c:969
    |<2>| ASSERT: gnutls_handshake.c:2762
    *** Fatal error: A TLS packet with unexpected length was received.
    |<4>| REC: Sending Alert[2|22] - Record overflow
    |<4>| REC[0xc65a70]: Sending Packet[1] Alert(21) with length: 2
    |<2>| errno: 32
    |<2>| ASSERT: gnutls_buffers.c:431
    |<2>| ASSERT: gnutls_buffers.c:755
    |<2>| ASSERT: gnutls_record.c:491
    *** Handshake has failed
    GnuTLS error: A TLS packet with unexpected length was received.
    |<4>| REC[0xc65a70]: Epoch #0 freed
    |<4>| REC[0xc65a70]: Epoch #1 freedSi il faut d'autres informations, n'hésitez pas, moi, je suis perdu :(
# Debug handshake
Posté par Nono (site web personnel) . Évalué à 1.
On m'a posé la question du handshake, mais la commande openssl en utilisant -prexit ou -msg ou même en spécifiant -tls1 ou -ssl3, rien n'y fait/ne m'aide.
de même
Donc, pas vraiment d'idée :/
# As-tu bien fait la conf ?
Posté par Jean-Yves LENHOF (site web personnel) . Évalué à 1.
Dans ton fichier slapd.conf, tu dois avoir des lignes qui ressemble à un truc du genre si je regarde la doc :
TLSCertificateFile /path/to/server-certificate.pem
TLSCertificateKeyFile /path/to/private-key.pem
TLSCACertificateFile /path/to/CA-certificates
Peux-tu déjà vérifier cela ?
[^] # Re: As-tu bien fait la conf ?
Posté par Bernez . Évalué à 2.
Et à la sauce « configuration dans le LDAP », il faut utiliser un LDIF de ce style :
dn: cn=config
changetype: modify
add: olcTLSCACertificateFile
olcTLSCACertificateFile: /etc/ldap/cacert.pem
-
add: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/ldap/db_key.pem
-
add: olcTLSCertificateFile
olcTLSCertificateFile: /etc/ldap/db_crt.pem
Si OpenLDAP utilise GnuTLS et que la clé privée a été générée par OpenSSL, il faut changer son format :
certtool --key-info < clé_OpenSSL > clé_GnuTLS
Sinon ton "openssl s_connect" ne fonctionnera pas sur le port 389 car OpenLDAP fait du STARTTLS sur ce port (en principe), et non du TLS direct.
[^] # Re: As-tu bien fait la conf ?
Posté par Nono (site web personnel) . Évalué à 1.
Merci de vos réponses, je vais répondre aux deux directement :
@Jean-Yves : Je n'utilise pas de slapd.conf (hormis celui dans /etc/default/) dont le contenu est déjà posté dans mon 1er post.
@Bernez : Concernant le port, c'est une erreur de ma part, j'ai bien effectué le test sur le port 636, et j’obtiens le même résultat : (note : le STARTTLS sur le port 389 semble fonctionner correctement)
Concernant la modification pour le ssl, j'avais utilisé ton propre ldif (venant d'ici : http://linuxfr.org/forums/linux-debian-ubuntu/posts/besoin-d-aide-debian-squeeze-open-ldap-et-ssl )
dont voici les deux appliqués :
Et effectivement, le certtool était/semble nécessaire, un ldd $(which slapd) m'indique bien du gnutls.
Mais, pas d'amélioration :(
Note : J'ai essayé d'enlever "olcSSL.ldif" (en remplacant les "add" par des "remove"), et là, au moins, je peux lancer mon deamon slapd correctement (pas d'erreur : main: TLS init def ctx failed: -1 )
[^] # Re: As-tu bien fait la conf ?
Posté par Nono (site web personnel) . Évalué à 1.
Hum, on recommence, j'avais fait de la merde sur les droits de lecture de mon certificat ..
L'erreur :
le ldapsearch "normal" fonctionne :
Le retour de openssl (qui n'est plus utile, suite au certtool, si j'ai bien compris ?!)
Enfin l'erreur avec gnutls-cli :
# Piste suggérée précédemment...
Posté par Jean-Yves LENHOF (site web personnel) . Évalué à 2.
As-tu bien fait l'étape certool parce que ton message "A TLS packet with unexpected length was received" fait quand même bien penser aux problèmes potentiels suggérés sur cette page :
https://wiki.debian.org/LDAP/OpenLDAPSetup
JY
[^] # Re: Piste suggérée précédemment...
Posté par Nono (site web personnel) . Évalué à 1.
Effectivement, je n'avais pas vu passer ces lignes ?!
J'ai donc recrée le certificat, modifié ma base comme demandé, et je me retrouve avec un beau :
# Distro ?
Posté par Jean-Yves LENHOF (site web personnel) . Évalué à 1.
Quelle est la distribution Linux utilisée et la version ?
[^] # Re: Distro ?
Posté par Nono (site web personnel) . Évalué à 1.
# Je ne sais pas si ca aide ...
Posté par Nono (site web personnel) . Évalué à 1.
Suivre le flux des commentaires
Note : les commentaires appartiennent à celles et ceux qui les ont postés. Nous n’en sommes pas responsables.