java 将 spring-ldap 与 ssl 一起使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6431383/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
using spring-ldap with ssl
提问by bmargulies
I need to talk to an LDAP server via spring-ldap with SSL, and the other end has a self-signed certificate no less.
我需要通过带有 SSL 的 spring-ldap 与 LDAP 服务器通信,而另一端也有一个自签名证书。
Can any kind soul please point me to some instructions for setting this up?
任何好心人都可以指点我一些设置说明吗?
采纳答案by helios
Check out Spring LDAPdocumentation for connecting to LDAP server over HTTP(S):
查看Spring LDAP文档以通过 HTTP(S) 连接到 LDAP 服务器:
As far as self signed certificate is concerned, you can import certificate chain into a truststore and set the following VM arguments:
就自签名证书而言,您可以将证书链导入信任库并设置以下 VM 参数:
-Djavax.net.ssl.trustStore="<path to truststore file>"
-Djavax.net.ssl.trustStorePassword="<passphrase for truststore>"
or override the truststore at runtime like:
或在运行时覆盖信任库,如:
System.setProperty("javax.net.ssl.trustStore","<path to truststore file>");
System.setProperty("javax.net.ssl.trustStorePassword","<passphrase for truststore>");
Keep in mind that both options will override default JVM truststore. So if you are hitting different sites with different certs, you may want to import all of them into one truststore.
请记住,这两个选项都将覆盖默认的 JVM 信任库。因此,如果您使用不同的证书访问不同的站点,您可能希望将它们全部导入到一个信任库中。
In case you need help creating truststore file, refer to this: Digital Certificate: How to import .cer file in to .truststore file using?
如果您在创建信任库文件时需要帮助,请参考:数字证书:如何使用 .cer 文件导入 .truststore 文件?
回答by launique
Note: If the other end is a trusted source then you might also skip the certification check, as I had to do because any few months the certificate was changed and I was constrained to import into my local truststore and the other environments' truststores, test, production, the new certificate, every single time.
注意:如果另一端是受信任的来源,那么您也可以跳过认证检查,因为我必须这样做,因为证书更改了几个月,并且我不得不导入到本地信任库和其他环境的信任库中,测试,生产,新证书,每一次。