在 jmeter 中启用服务器证书身份验证 [英] Enabling server certificate authentication in jmeter

查看:17
本文介绍了在 jmeter 中启用服务器证书身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我想在 jmeter 中启用服务器证书的身份验证.可以配置吗?

As the title says, i'd like to enable the authentication of server certificates in jmeter. Is it possible to configure it?

到目前为止我发现的是这篇文章据此,HTTP Client 4 实现将使用 TrustAll 方案".我主要使用这个客户端实现(在 jmeter 3.0 或 3.1 版中),因为这是 jmeter 中更高级/更通用的.但是这样 jmeter 就不会发现服务器证书无效的情况.

What i found so far is this article According to this, "HTTP Client 4 implementation will use a TrustAll scheme". Mainly i use this client implementation (in jmeter version 3.0 or 3.1) since this is the more advanced/versatile in jmeter. But this way jmeter won't catch cases where server certificates are invalid.

推荐答案

根据 JMeter 文档:

JMeter HTTP 采样器被配置为接受所有证书,无论可信与否,无论有效期等.这是为了在测试服务器时提供最大的灵活性.

The JMeter HTTP samplers are configured to accept all certificates, whether trusted or not, regardless of validity periods, etc. This is to allow the maximum flexibility in testing servers.

在不修改 JMeter 源代码的情况下没有简单的方法来禁用此行为,但是您可以使用 JSR223 Sampler 以检查服务器证书和/或证书链.

There is no easy way of disabling this behavior without modification of JMeter source code, however you can use JSR223 Sampler in order to check the server certificate and/or certificate chain.

相关代码类似于:

def factory = javax.net.ssl.SSLSocketFactory.getDefault();

def socket = factory.createSocket('example.com', 443);

socket.withStreams { input, output ->
    output.withWriter {
        it << 'hello'
        it.flush()
    }
}

example.com443 替换为您的服务器主机和端口.如果证书没有问题 - 请求将成功,否则您将在示例结果中看到带有详细信息的错误.

Replace example.com and 443 with your server host and port. If there is no problem with certificate(s) - the request will be successful, otherwise you will see error with details in the sample result.

查看Apache Groovy - 为什么以及如何使用它文章详细了解 JMeter 中自定义脚本的概念

Check out Apache Groovy - Why and How You Should Use It article to learn more about the concept of custom scripting in JMeter

这篇关于在 jmeter 中启用服务器证书身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆