gpt4 book ai didi

ssl - Spring Security,ssl ldap,没有证书

转载 作者:太空宇宙 更新时间:2023-11-03 12:55:53 25 4
gpt4 key购买 nike

我使用 spring security 来管理登录。我已经将 spring security 配置为连接到使用 ssl (ldaps) 保护的 ldap 服务器。

此服务器是测试服务器,没有有效证书。当我尝试测试登录时,spring security 提示无法验证证书(当然!):

sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target

我的问题很简单:我不想管理任何类型的证书,我想停用证书检查并继续使用 ssl ldap。我该怎么做?

最佳答案

听起来好像LDAP服务器的证书只是自证而不是无效。

对我来说,最简单的解决方案是获取该证书并将其添加到 java 中的 cacerts 信任库中。完成后,代码将无需任何修改即可运行。

从服务器获取证书:

$ openssl s_client -showcerts -connect ldapserver:636

输出将包含许多用

分隔的条目
-----BEGIN CERTIFICATE-----
aklfhskfadljasdl1340234234ASDSDFSDFSDFSDFSD
....
-----END CERTIFICATE-----

将最后一个证书条目复制到文件 (ldapca.crt)

然后,将其添加到 $JRE_HOME/lib/security 中的 java keystore

$ cd $JRE_HOME/lib/security
$ keytool -import -alias ldapca_self_sign -keystore cacerts -storepass changeit -file ldapca.crt

这意味着,您将信任 LDAP 服务器上的证书,并在您的测试环境中正确使用 SSL(而不是使用一些自定义代码来关闭部分 SSL 检查)。

完成该操作(一次)后,您的代码应该无需任何修改即可运行。

关于ssl - Spring Security,ssl ldap,没有证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9903560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com