openldap TLS error -8179:Peer's Certificate issuer is not recognized

tl;dr Does this error mean that I need to find my company's ldap server's public certificate and install it, or that my company's ldap server needs to install my public cert? If the former, how can I grab the certs and install it?


I'm attempting to integrate an application with my company's LDAP. I'm very new to LDAP and SSL so I apologize in advance. I can do this successfully on non-ssl but am hitting this issue when I attempt to do this over SSL. I am on a Rhel 6.4 with openldap version 2.4.

Using either ldapsearch

ldapsearch -v -h myhost.com -b 'DC=myhost,DC=com, -D 'CN=me,DC=myhost,DC=com' -x -W -Z

or Python

import ldap
con = ldap.initialize('ldaps://myhost.com')
dn = 'CN=me,DC=myhost,DC=com'
pw = 'password'
con.simple_bind_s(dn, pw)

results in:

ldap_start_tls: Connect error (-11)
    additional info: TLS error -8179:Peer's Certificate issuer is not recognized.

Does this mean that I need to find my company's ldap server's public certificate and install it somewhere, for example, /etc/openldap/certs? Or, does it mean that I need to tell my company's ldap server to approve my public certificate?

openssl s_client -connect myhost.com:636

This dumps a certificate, but at the end says:

Verify return code: 20 (unable to get local issuer certificate)

Again, I'm unsure if this means that I need the ldap server's certs or vice versa.

I did try to see the certificate chain like this:

openssl s_client -showcerts -connect myhost.com:636

I copied the certificates in order and made a file like so, named cert.pem:

-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----

I tried this:

openssl s_client -connect myhost.com:636 -cert /path/to/cert.pem 

but it failed with:

unable to load client certificate private key file
140503604590408:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:
Expecting: ANY PRIVATE KEY

(I also tried -CAfile and -CApath on this, but I received the unable to get local issuer certificate.)

I recreated the pem file but this time included my server's private key, and cert, followed by the ldap server's certs, but received the same error (Verify return code: 20 (unable to get local issuer certificate)) again.

Am I creating these certificate files incorrectly?

1
задан 10 February 2016 в 05:15
2 ответа

Причина, по которой я получил эти ошибки, заключалась в том, что на моем сервере не были установлены сертификаты сервера ldap. На сервере ldap не обязательно должны быть установлены сертификаты моего сервера.

Я связался с кем-то в моей компании, который смог предоставить два сертификата, корневой сертификат и промежуточный сертификат, оба в формате der . Примечательно, что эти сертификаты не были такими же , как те, которые я получил с помощью команды openssl s_client -showcerts . Я перешел по этой ссылке , чтобы преобразовать их из der в pem , например:

openssl x509 -in root.cer -inform der -outform pem -out root.pem
openssl x509 -in intermediary.cer -inform der -outform pem -out intermediary.pem
# Combine these files into one cert in exactly this order
cat root.pem > master.pem
cat intermediary.pem >> master.pem

Затем я мог бы выполнить эту команду нормально

openssl s_client -connect myhost:636 -CAfile /path/to/master.pem

И подключиться в Python:

import ldap
# point to the cert
cert_file='/path/to/master.pem'
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, cert_file)
con = ldap.initialize('ldaps://myhost.com')
dn = 'CN=me,DC=myhost,DC=com'
pw = 'password'
con.simple_bind_s(dn, pw)
2
ответ дан 3 December 2019 в 20:42

Openldap 2.4 использует порт по умолчанию 398 для tls, поэтому попробуйте s_client через него. Вы можете проверить файлы конфигурации в /etc/openldap/slapd.d/, проверить файл экземпляра базы данных cn = olcDatabase = {2} hdb.ldif.Этот файл может содержать имена файлов и расположение ваших сертификатов. Если ваша компания покупает сертификаты у поставщика домена, такого как goDaddy, вы можете приобрести и использовать его сертификаты для установки с помощью openldap, и когда вы просматриваете Интернет, вы не встретите красное предупреждение от браузеров, потому что это всемирные сертификаты. Или вы можете создать свои собственные сертификаты с использованием openssl и установить часть сертификата сервера на свой сервер openldap и установить клиентскую часть на свой клиент, чтобы они могли идентифицировать друг друга.

0
ответ дан 3 December 2019 в 20:42

Теги

Похожие вопросы