一 、初始化环境变量
## 步骤一:初始化环境变量
export CERT_OUTPUT_PATH="/usr/jmev"
export NODE_ALIAS=efl
export TRUST_STORE="$CERT_OUTPUT_PATH/${NODE_ALIAS}.truststore.jks"
export ROOT_CER_FILE="$CERT_OUTPUT_PATH/${NODE_ALIAS}.truststore.cer"
export PASSWORD="qwerty"
export TRUST_KEY_PASSWORD=$PASSWORD
export TRUST_STORE_PASSWORD=$PASSWORD
# 证书输出的根目录 如果不存在 就创建
if [ ! -d ${CERT_OUTPUT_PATH} ]; then
mkdir -p ${CERT_OUTPUT_PATH}
fi
二、步骤二:下载cer证书
if [ -f "$ROOT_CER_FILE" ];then
echo -n | rm -f "$ROOT_CER_FILE"
fi
echo -n | openssl s_client -connect easyconnectforfleet.renault.com:443 -servername easyconnectforfleet.renault.com \
| openssl x509 > "$ROOT_CER_FILE"
三:cer证书 转成jks证书
if [ -f "$TRUST_STORE" ];then
echo -n | rm -f "$TRUST_STORE"
fi
keytool -keystore "$TRUST_STORE" \
-alias "easyconnectforfleet" \
-importcert \
-file "$ROOT_CER_FILE" \
-storepass "$TRUST_STORE_PASSWORD" \
-keypass "$TRUST_KEY_PASSWORD" \
-noprompt