通过 SSL 的 Postgresql LDAP 身份验证

标签 postgresql ssl ldap

我如何在 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,尽管密码按预期方式未加密发送。

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

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"

欢迎任何想法。

最佳答案

根据 documentation,Postgres 现在从版本 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"

关于通过 SSL 的 Postgresql LDAP 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21589794/

相关文章:

python - GIS:Python 中的 line_locate_point()

sql - Postgres : Issue Creating a User

ruby-on-rails - 需要 Rails 的 HTTPS/SSL 速成类

javascript - 如何在2个php文件之间传递变量

自上个月以来获得最多评论的 SQL 查询

arrays - 如何获取 ARRAY 列的维度?

php - 将长 URL 重定向到 https

apache-flex - 在 Flex 4 中使用 HTTPS Web 服务

active-directory - 我需要从 ldap 中找出禁用的用户

ldap - 使用 SASL 的 Gitlab LDAP