我手里有一个SSL LDAP服务器证书。我想用它来使用UnboundID SDK连接到LDAP服务器。如何使用UnboundID SDK通过SSL服务器证书连接到LDAP服务器?
我不想用com.unboundid.util.ssl.TrustAllTrustManager因为在这里显示: Using UnboundID SDK with an SSL certificate file to connect to LDAP server in Android app
以下TrustManagers不适合我们的产品要求:
com.unboundid.util.ssl.PromptTrustManager
com.unboundid.util.ssl.HostNameTrustManager
com.unboundid.util.ssl.ValidityDateTrustManager
我不想任何用户交互,以及我在TrustManager上方列表中错过的验证证书颁发者的内容。
而且,我不想插入任何密钥库的LDAP服务器证书,所以我不能使用以下 TrustManagers:
com.unboundid.util.ssl.WrapperKeyManager
com.unboundid.util.ssl.PKCS11KeyManager
com.unboundid.util.ssl.KeyStoreKeyManager
我想要做的东西像下面的代码:
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate cert = cf.generateCertificate(byteArrayInputStream);
SSLUtil sslUtil = new SSLUtil(new CertificateTrustManager(cert));
SSLSocketFactory socketFactory = sslUtil.createSSLSocketFactory();
LDAPConnection connection = new LDAPConnection(socketFactory,
"server.example.com", 636);
请注意,CertificateTrustManager在UnboundID SDK中不存在。 怎么可能做到这一点?
感谢您的回答(+1)!我找到了解决方案。很高兴听取您的意见。 – Michael