忽略/关闭 Jmeter/Java 中的证书验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33339172/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 21:31:48  来源:igfitidea点击:

Ignore/Turn off verification of the certificate in Jmeter/Java

javajmeterssl-certificatekeystoreca

提问by sidman

I am testing HTTPS Requests to a custom server using JMeter, but the certificate that the custom server returns in untrusted (as this is a development server). Because of this, the requests fail as it needs a signed/verified CA Certificate.

我正在使用 JMeter 测试对自定义服务器的 HTTPS 请求,但自定义服务器返回的证书不受信任(因为这是一个开发服务器)。因此,请求失败,因为它需要签名/验证的 CA 证书。

Is there a way to turn off Jmeter's certificate verification similar to curl (-k option) ?

有没有办法关闭类似于 curl(-k 选项)的 Jmeter 证书验证?

回答by pawinder gupta

You can include the certificate from the development server in Jmeter jvm.

您可以在 Jmeter jvm 中包含来自开发服务器的证书。

  1. Download the certificate using any of the browsers. Here is a linkon how to do this.

  2. Identify the jvm that Jmeter uses. This is generally your JAVA_HOME environment varaible.

  3. Add the certificate to the jvm truststore. Here are the steps.

  1. 使用任何浏览器下载证书。这是有关如何执行此操作的链接

  2. 确定 Jmeter 使用的 jvm。这通常是您的 JAVA_HOME 环境变量。

  3. 将证书添加到 jvm 信任库。以下是步骤

That should fix it.

那应该解决它。

回答by Vishal Kharde

JMeter does not validate certificates by default, it ignores all certificate errors such as expiry and incorrect hostname. https://cwiki.apache.org/confluence/display/JMETER/JMeterAndHTTPS

JMeter 默认不验证证书,它会忽略所有证书错误,例如过期和不正确的主机名。https://cwiki.apache.org/confluence/display/JMETER/JMeterAndHTTPS

If you are still facing this issue, then you can explicitly mention the properties to ignore ssl certificate check. It can be done in two ways,

如果您仍然面临此问题,那么您可以明确提及忽略 ssl 证书检查的属性。它可以通过两种方式完成,

  1. Add a JMeter start-up configuration. You just have to look for the jmeter.properties file and add the code line ‘server.rmi.ssl.disable=true'

  2. Executing Jmeter through command line by passing parameter to rewrite properties of the configuration files at start-up,

    jmeter -s -Jserver.rmi.ssl.disable=true

  1. 添加 JMeter 启动配置。您只需要查找 jmeter.properties 文件并添加代码行“server.rmi.ssl.disable=true”

  2. 在启动时通过传递参数来重写配置文件的属性,通过命令行执行Jmeter,

    jmeter -s -Jserver.rmi.ssl.disable=true

Also check if correct headers are passed,

还要检查是否传递了正确的标题,

Accept-Enconding= application/json
Content-Type= application/json