简体   繁体   English

在 JMeter 中使用 AWS SSL 证书

[英]Using the AWS SSL certificate in JMeter

I have a collection in documentdb in which I need to verify the contents using JMeter. I'm relatively new to JMeter and I was wondering how I can connect JMeter to AWS document db.我在 documentdb 中有一个集合,我需要使用 JMeter 验证其中的内容。我对 JMeter 比较陌生,我想知道如何将 JMeter 连接到 AWS 文档数据库。 I tried using the SSL manager to use the rds-combined-ca-bundle.pem but it does not work with pem files.我尝试使用 SSL 管理器来使用 rds-combined-ca-bundle.pem 但它不适用于 pem 文件。 How can I use this pem file in JMeter?我如何在 JMeter 中使用这个 pem 文件?

You need to convert the PEM file to the.p12 using either OpenSSL tool like:您需要使用OpenSSL 工具将 PEM 文件转换为 .p12,例如:

openssl pkcs12 -in certificate.pem -out certificate.p12 -nodes

Alternatively you can use the keytool and import the certificate into existing.p12 Java Keystore或者,您可以使用keytool 并将证书导入到 existing.p12 Java Keystore

keytool -import -v -alias your-certificate-alias-here -file certificate.pem -keystore certificate.p12

Once done you can specify the path to the certificate and its password in JMeter's system.properties file like完成后,您可以在 JMeter 的system.properties文件中指定证书的路径及其密码,例如

javax.net.ssl.keyStore=certificate.p12
javax.net.ssl.keyStorePassword=changeit

and after JMeter restart it will send encrypted requests to the backend. JMeter 重新启动后,它将向后端发送加密请求。

More information: How to Set Your JMeter Load Test to Use Client Side Certificates更多信息: 如何设置 JMeter 负载测试以使用客户端证书

Use this script to import the.pem certificate for Amazon DocumentDB to the keystore:使用此脚本将 Amazon DocumentDB 的 .pem 证书导入密钥库:

#!/bin/bash

mydir=/tmp/certs
truststore="$mydir"/rds-truststore.jks
storepassword="truststorePassword" # at least 6 characters

mkdir -p "$mydir"; cd "$mydir" || exit
curl -sS "https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem" > "$mydir"/rds-combined-ca-bundle.pem
awk 'split_after == 1 {n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1}{print > "rds-ca-" n ".pem"}' < "$mydir"/rds-combined-ca-bundle.pem

for CERT in "$mydir"/rds-ca-*; do
  alias=$(openssl x509 -noout -text -in "$CERT" | perl -ne 'next unless /Subject:/; s/.*(CN=|CN = )//; print')
  echo "Importing $alias"
  keytool -import -file "$CERT" -alias "$alias" -storepass "$storepassword" -keystore "$truststore" -noprompt
  rm -f "$CERT"
done

rm -f "$mydir"/rds-combined-ca-bundle.pem

echo "Trust store content is: "

keytool -list -v -keystore "$truststore" -storepass "$storepassword" | grep Alias | cut -d " " -f3- | while read -r alias 
do
   expiry=$(keytool -list -v -keystore "$truststore" -storepass "$storepassword" -alias "$alias" | grep Valid | perl -ne 'if(/until: (.*?)\n/) { print "$1\n"; }')
   echo " Certificate ""$alias"" expires in '$expiry'" 
done

Then update system.properties as mentioned above with the location of the keystore and its password.然后使用密钥库的位置及其密码如上所述更新 system.properties。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM