【问题标题】:Jenkins unable to connect to ldaps://serverJenkins 无法连接到 ldaps://server
【发布时间】:2015-05-20 13:18:06
【问题描述】:

我正在尝试将 Jenkins 连接到 LDAP 服务器。我在 Jenkins 上设置了配置,但我收到了他的消息:

无法连接到 ldaps://ldap.my.server.com : javax.naming.CommunicationException: simple bind failed: ldap.my.server.com:636 [root exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径]

我知道是因为我的 SSL 证书是自签名的,但是,有什么方法可以让我在 jenkins 中忽略它?

【问题讨论】:

    标签: java ssl jenkins ldap


    【解决方案1】:

    您的信任库不信任服务器证书。如果它是自签名的,您需要将其从服务器导出并将其导入您的客户端信任库。更好的是,把它签名。

    【讨论】:

    • 为了测试目的,我需要它是未签名的。
    【解决方案2】:

    您是否考虑过完全跳过证书验证? 这是我前段时间在解决同一个问题时发现的一段代码:

    public static void trustSelfSignedSSL() {
        try {
            SSLContext ctx = SSLContext.getInstance("TLS");
            X509TrustManager tm = new X509TrustManager() {
    
                @Override
                public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                }
    
                @Override
                public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                }
    
                @Override
                public X509Certificate[] getAcceptedIssuers() {
                    return null;
                }
            };
            ctx.init(null, new TrustManager[] { tm }, null);
            SSLContext.setDefault(ctx);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    

    希望这会有所帮助

    【讨论】:

    • 完全不安全,不遵守自己的合同。
    • 我同意并建议仅将这种方法用于测试目的
    猜你喜欢
    • 1970-01-01
    • 2022-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-05
    相关资源
    最近更新 更多