【问题标题】:JMeter Ignore SSL Security CertificateJMeter 忽略 SSL 安全证书
【发布时间】:2023-03-25 22:00:02
【问题描述】:

我在尝试连接到 LDAP 服务器时收到以下错误。 有没有办法忽略 SSL 安全证书。我可以使用其他工具连接到 JMeter 之外的服务器。

Thread Name: Thread Group 1-1
Sample Start: 2018-09-23 12:16:48 EDT
Load time: 154
Connect Time: 0
Latency: 0
Size in bytes: 555
Sent bytes:0
Headers size in bytes: 0
Body size in bytes: 555
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 800
Response message: javax.naming.CommunicationException: x.x.x.x:1636 
[Root exception is javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target]

Response headers:


SampleResult fields:
ContentType: text/xml
DataEncoding: UTF-8

【问题讨论】:

    标签: ssl jmeter


    【解决方案1】:

    解决此问题的最佳(也是最常见的)方法是信任 LDAPS 服务器,即使用 keytool 将服务器的证书添加到 JRE 的 cacerts 文件中。已经有一个关于如何做到这一点的简单答案(这里:Is there a java setting for disabling certificate validation?) - 要点是(取自那里)

    cd %JRE_HOME%
    keytool -alias REPLACE_TO_ANY_UNIQ_NAME -import -keystore ..\lib\security\cacerts -file your.crt
    

    当您还没有公钥(证书文件)时,您可以例如通过使用 Apache Directory Studio (https://directory.apache.org/studio/) 连接到 LDAPS 服务器来获取它,该服务器存储您信任的 LDAPS 服务器的所有公钥。邮件列表中已经描述了确切的例程(此处:http://mail-archives.apache.org/mod_mbox/directory-users/201004.mbox/%3C4BBF6471.6040900@apache.org%3E),所以我只是给出要点(再次主要取自那里)

    find ~/.ApacheDirectoryStudio -name \*.jks # gives you the keystores managed by DirectoryStudio
    keytool -list -keystore path/to/permanent.jks
    keytool -exportcert -alias <aliasname> -keystore path/to/permanent.jks -file your.crt
    

    【讨论】:

    • 感谢您的回复。所以我运行 keytool -list -keystore path/to/permanent.jks 的第一个命令要求输入密码,我根据某个论坛中的一个答案输入了 changeit 但第二个命令也要求输入密码,我不确定在那里输入什么,别名是什么?谢谢
    • 只要你不做任何事情,所有的密钥库密码都是'changeit'。别名是第一次运行 keytool 为您提供的:list 提供了带有别名、日期、类型、指纹的证书列表 - 您需要第一部分(别名)
    • 所以我现在能够执行第二个命令,但 JMeter 仍然无法连接并给我同样的错误?可能缺少什么?我也不确定 your.crt 是什么。我排除了那部分,因为它不是邮件存档帖子的链接。
    • 您必须从 Directory studio 导出(或从其他地方获取证书),然后将证书导入您运行 JMeter 的 JRE 的 cacerts...
    【解决方案2】:

    这很可能表明您的 LDAP 服务器 SSL 设置存在问题,即无法根据权限检查链中的证书之一。我建议使用即仔细检查证书链

    • OpenSSL tool 喜欢:openssl s_client -showcerts -connect yourhost:yourport
    • SSLPoke 类似工具:java -Djavax.net.debug=ssl SSLPoke yourhost yourport

    你有两种方法:

    1. Add the certificate into the JVM truststore点赞:

      keytool -import -file your_ldap_certificate -alias certificate -keystore trustStore.keystore 
      
    2. 创建custom class which will be trusting all the certificates并设置java.naming.ldap.factory.socket系统属性指向该类(该类必须在JMeter Classpath中)

    如果您需要有关使用 JMeter 进行 LDAP 服务器性能测试的更多信息,请查看 How to Load Test LDAP with Apache JMeter™ 文章。

    【讨论】:

      猜你喜欢
      • 2023-03-31
      • 2011-08-26
      • 2019-02-28
      • 1970-01-01
      • 2016-01-28
      • 2019-09-02
      • 1970-01-01
      • 1970-01-01
      • 2016-08-04
      相关资源
      最近更新 更多