Search code examples
jmeterssl-certificatekeystoreclient-certificates

Jmeter: "No certificate found for alias"


I'm having a problem trying to get a client-side certificate loaded using Jmeter. I believe I followed this tutorial, but am getting an error when running my tests.

From what I can tell, it seems like my keystore file is set up correctly. If I run keytool -list -v -keystore <mykeystore> I get:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: client
Creation date: Jul 31, 2017
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
<certificate body>

When I run my tests, things seem to be running okay from the beginning

Total of 1 aliases loaded OK from keystore

However, in the results output I see the error message:

java.lang.IllegalArgumentException: No certificate found for alias:'client'

What could be causing Jmeter to fail reading the certificate?


Solution

  • For non-telepathic JMeter experts it will be quite hard to provide the answer without knowing your exact configuration steps so I will just come up with a solution that definitely works:

    1. Revert all your configuration changes (or just get a clean JMeter from downloads page)

    2. Add the next lines to system.properties file (lives in the "bin" folder of your JMeter installation)

      javax.net.ssl.keyStoreType=pkcs12 or jks  
      javax.net.ssl.keyStore=/path/to/your/jks keystore or .p12 certificate
      javax.net.ssl.keyStorePassword=your certificate or keystore password 
      
    3. Restart JMeter to pick the properties up (if you pass the properties via -D command-line argument like jmeter -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStore=secret.p12 ... - restart will not be required)

    That's it, now your outgoing HTTP Requests will be encrypted using the certificate provided.

    More information: