【问题标题】:SSL in two ways not working for my OpenLDAP两种方式的 SSL 不适用于我的 OpenLDAP
【发布时间】:2013-12-28 02:44:32
【问题描述】:

我正在尝试测试 JAVA 客户端和 OpenLDAP 服务器之间的 SSL 2 路连接(握手)。

     System.setProperty("javax.net.ssl.trustStore","C:\\Program Files (x86)\\Java\\jre7\\lib\\security\\cacerts");
     System.setProperty("javax.net.ssl.trustStorePassword","changeit");
     System.setProperty("javax.net.debug","ssl");

     Hashtable env = new Hashtable();
     env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
     // Specify SSL
     env.put(Context.SECURITY_PROTOCOL, "SSLv3");


     System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");  
     System.setProperty("javax.net.ssl.keyStore", "C:\\OpenLDAP\\etc\\certs\\client.p12");  
     System.setProperty("javax.net.ssl.keyStorePassword", "password");

     env.put(Context.PROVIDER_URL, "ldaps://localhost:636");

我使用默认参数安装了 OpenLDAP,并将 server.pem 导出到上面的信任库。 从日志中我可以看到 serverHello 完成后握手失败,我猜是尝试获取客户端证书的问题。 我所做的配置有什么问题?

【问题讨论】:

  • 请使用 -Djavax.net.debug=ssl 运行您的客户端,握手并将结果编辑到您的问题中。

标签: java ssl openldap


【解决方案1】:

您需要将服务器证书添加到 Java 的密钥库,因为我假设它是自签名的。

您可以使用获取证书

openssl s_client -connect [主机名]:[端口例如443] /tmp/lb.cert

然后将证书添加到您的密钥库

keytool -importcert -keystore [keystore 位置,不同,但可以是 e.g. /etc/pki/java/cacerts] -storepass changeit -file /tmp/lb.cert -alias newSelfSignedKey -noprompt

【讨论】:

    猜你喜欢
    • 2015-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-11
    • 2019-02-05
    • 2015-10-27
    • 1970-01-01
    相关资源
    最近更新 更多