| title | Use Multiple Certificates in Azure Load Testing |
|---|---|
| titleSuffix | Azure Load Testing |
| description | Learn how to configure and use multiple certificates securely in Azure Load Testing with a JKS file and Key Vault integration. |
| services | load-testing |
| ms.service | azure-load-testing |
| ms.author | nandinim |
| author | nandinimurali |
| ms.date | 01/24/2025 |
| ms.topic | how-to |
Azure Load Testing supports the use of multiple certificates for secure communication during load testing scenarios. This article explains how to consolidate multiple certificates into a Java KeyStore (JKS) file, securely store the keystore password in Azure Key Vault (AKV), and configure Azure Load Testing to use the JKS file.
Before you begin, ensure the following:
- You have an Azure Key Vault instance set up to store secrets.
- You have the Managed Identity (MI) of your Azure Load Testing resource configured.
- You have created a Java KeyStore (JKS) file containing all required certificates.
- You have stored the JKS password as a secret in Azure Key Vault.
- Use the keytool utility to create a JKS file and import all necessary certificates.
keytool -importcert -file <certificate-file> -keystore <keystore-name>.jks -alias <alias-name> - Store the JKS file's password as a secret in Azure Key Vault:
- Open the Azure portal and navigate to your Key Vault.
- Select Objects > Secrets > Generate/Import.
- Enter a name and the password for the JKS file, then click Create.
- In the Azure portal, go to your Azure Key Vault resource and select Access Policies from the left pane, then click + Create.
- On the Permissions tab:
- Under Secret permissions, select Get.
- Click Next.
- On the Principal tab:
- Search for and select the managed identity for the load testing resource.
- Click Next.
- If you're using a system-assigned managed identity, the managed identity name matches that of your Azure Load Testing resource.
- Click Next again to complete the access policy configuration.
When your test runs, the managed identity associated with your load testing resource can now read the secret for your load test from your Key Vault. Now that you've added a secret in Azure Key Vault and configured a secret for your load test, move to use secrets in Apache JMeter.
Keystore configuration
- In your JMeter script, add the Keystore Configuration element to manage SSL certificates.
- Go to Test Plan > Add > Config Element > Keystore Configuration.
- Set the Alias field to match the certificate alias in your JKS file.
JSR223 PreProcessor for dynamic SSL configuration
- Add a JSR223 PreProcessor to dynamically configure the SSL properties at runtime.
- Go to Thread Group > Add > PreProcessors > JSR223 PreProcessor.
- Set the language to Java.
- Add the following script:
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12"); System.setProperty("javax.net.ssl.keyStore", "<path-to-your-keystore>"); System.setProperty("javax.net.ssl.keyStorePassword", "<keystore-password>");
- Replace
path-to-your-keystoreandkeystore-passwordwith your actual keystore file path and password.
- In your JMeter script, add a CSV Data Set Config element to iterate over the certificates in your JKS file.
- Go to Test Plan > Add > Config Element > CSV Data Set Config.
- Configure the following fields:
- Filename: Path to the CSV file containing certificate aliases.
- Variable Names: Name of the variable (e.g., certificateAlias).
- Create a CSV file with a list of certificate aliases from your JKS file. Each alias should be on a new line.
- Use the variable (e.g., ${certificateAlias}) in the Keystore Configuration or scripts to dynamically reference the current certificate alias during the test execution.
- In the Azure portal, navigate to your Azure Load Testing resource and start a new test creation workflow.
- Upload the following files:
- The JKS file.
- Your JMeter test script.
- The CSV file with certificate aliases.
- Go to the Parameters tab in the test creation workflow.
- Add a secret for the JKS password:
- Name: The name of the secret in Azure Key Vault.
- Value: The Key Vault URL (e.g., https://
key-vault-name.vault.azure.net/secrets/secret-name).
- Configure the Key Vault reference identity, by specifying the Managed Identity of the Azure Load Testing resource that will access the Key Vault secret.
Review all configurations to ensure correctness. Click Create Test to finalize and run the test.