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

查看:427
本文介绍了在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源代码的禁用此行为的简便方法,但是您可以使用证书链.

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天全站免登陆