Enabling server certificate authentication in jmeter

后端 未结 1 977
一向
一向 2021-01-28 21:32

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

What i found so far is this article According

相关标签:
1条回答
  • 2021-01-28 22:02

    According to JMeter Documentation:

    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.

    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.

    The relevant code would be something like:

    def factory = javax.net.ssl.SSLSocketFactory.getDefault();
    
    def socket = factory.createSocket('example.com', 443);
    
    socket.withStreams { input, output ->
        output.withWriter {
            it << 'hello'
            it.flush()
        }
    }
    

    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.

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

    0 讨论(0)
提交回复
热议问题