Jmeter-如何包含外部.p12 SSL证书

时间:2017-04-03 09:07:58

标签: jmeter

exception Jmeter throws- 
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at com.ibm.jsse2.qc.a(qc.java:422)
    at com.ibm.jsse2.qc.h(qc.java:714)
    at com.ibm.jsse2.qc.a(qc.java:831)
    at com.ibm.jsse2.qc.startHandshake(qc.java:828)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:553)
    at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:412)
    at org.apache.jmeter.protocol.http.sampler.LazySchemeSocketFactory.connectSocket(LazySchemeSocketFactory.java:97)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:179)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:328)
    at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.open(MeasuringConnectionManager.java:114)

是否需要使用任何特定的Java版本? Jmeter版本是 - 3.1

1 个答案:

答案 0 :(得分:1)

  1. 只需将下一行添加到 system.properties 文件(位于JMeter安装的“bin”文件夹中)

    javax.net.ssl.keyStoreType=pkcs12    
    javax.net.ssl.keyStore=/path/to/your/certificate.p12
    javax.net.ssl.keyStorePassword=your_certificate_password_here
    

    另一种选择是通过-D命令行参数提供上述属性,如:

    jmeter -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStore=/path/to/your/certificate.p12 -Djavax.net.ssl.keyStorePassword=your_certificate_password_here
    

    这对于无人值守的执行更方便,即使用Continuous Integration服务器

  2. 重新启动JMeter以选择属性
  3. 现在JMeter将使用您的客户端证书进行请求加密
  4. 有关详细信息,请参阅How to Set Your JMeter Load Test to Use Client Side Certificates

    或者您可以使用SSL Manager,但我个人认为使用系统属性更方便。