首页 文章

通过SSL进行Postgresql LDAP身份验证

提问于
浏览
1

如何在Ubuntu服务器12.04上设置postgresql 9.1以通过SSL对Windows AD服务器使用LDAP身份验证 .

客户端SSL已设置并在postgresql中工作 .

没有SSL的LDAP工作 .

在pg_hba.conf中我有这个:

hostssl  ldaptest all   0.0.0.0/0 ldap ldapserver="myldapserver.local" ldapprefix="cn=" ldapsuffix=", ou=TestOU, dc=sub, dc=example, dc=local"

我可以使用psql连接,但密码是按预期未加密发送的 .

如果我将其设置为在普通端口上使用TLS(389):

hostssl  ldaptest all   0.0.0.0/0 ldap ldapserver="myldapserver.local" ldapprefix="cn=" ldapsuffix=", ou=TestOU, dc=sub, dc=example, dc=local" ldaptls=1

我明白了:

could not start LDAP TLS session: error code -11

如果我将其设置为使用LDAPS端口(636)来使用SSL:

hostssl  ldaptest all   0.0.0.0/0 ldap ldapserver="myldapserver.local" ldapprefix="cn=" ldapsuffix=", ou=TestOU, dc=sub, dc=example, dc=local" ldaptls=0 ldapport=636

我明白了:

LDAP login failed for user "cn=Teszt User,ou=TestOU,dc=sub,dc=example,dc=local" on server "ratotdc.okologia.mta.local": error code -1

如果我打开两个TLS并将端口设置为636我得到:

could not start LDAP TLS session: error code -11

我在ldap.conf中有服务器证书:

TLS_CACERT      /root/certs/infolabtest_cert.cer

ldapsearch通过SSL工作并返回正确的结果:

ldapsearch -W -H ldaps://myldapserver:636/ -D "CN=Teszt User,OU=TestOU,DC=sub,DC=example,DC=local" -b "ou=testou,dc=sub,dc=example,dc=local" "CN"

欢迎任何想法 .

2 回答

  • 1

    这有点困难 . 我在这里找到了答案:http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol

    保护LDAP通信的常用替代方法是使用SSL隧道 . 这在LDAP URL中使用URL方案“ldaps”表示 . LDAP over SSL的默认端口是636.在LDAP版本2(LDAPv2)中使用LDAP over SSL是常见的,但它在任何正式规范中从未标准化 . 此用法已与LDAPv2一起弃用,LDAPv2于2003年正式退役 .

    Posgres不支持LDAPv2(e.i . ldpas://), but it does support LDAPv3 TLS

  • 1

    Postgres现在根据documentation从版本11开始支持 ldaps://

    所以pg_hba.conf中的配置如下所示:

    host  ldaptest all   0.0.0.0/0 ldap ldapulr="ldaps://myldapserver.local:636/ou=testou,dc=sub,dc=example,dc=local?cn?sub"
    

相关问题