环境自签名证书,不受浏览器、jre/jdk 证书库信任,会导致某些工程SSL 通讯异常。
解决办法是将该证书导出后,再导入到各应用节点 jre/jdk 证书库。
$ cat keytool_import.sh
#!/bin/bash
domain_name="www.example.com"
domain_port="443"
cert_alias="www.example.com"
export JAVA_HOME="/opt/jdk"
echo | openssl s_client -showcerts -connect ${domain_name}:${domain_port} 2> /dev/null | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' > ${cert_alias}.cer
cat ${cert_alias}.cer
keytool -import -file ${cert_alias}.cer -alias ${cert_alias} -keystore ${JAVA_HOME}/jre/lib/security/cacerts --storepass "changeit" --noprompt -trustcacerts
keytool -list -rfc -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass "changeit" | grep -i "${cert_alias}"
网友评论