配置CA证书

前置条件

配置Java环境变量。

具体操作

windows环境

以管理员方式执行CMD窗口,输入命令;

cd /d %JAVA_HOME%\jre\lib\security

curl -kv https://xxx/artifactory/CMC-Release/certificates/xxxRootCA.cer -o xxxRootCA.cer

curl -kv https://xxx/artifactory/CMC-Release/certificates/xxxEnterpriseCA1.cer -o xxxEnterpriseCA1.cer

keytool -keystore cacerts -importcert -alias xxxRootCA -file xxxRootCA.cer -storepass changeit -noprompt

keytool -keystore cacerts -importcert -alias xxxEnterpriseCA1 -file xxxEnterpriseCA1.cer -storepass changeit -noprompt

上述操作即在jdk的security包目录下调用curl命令把对应的根CA和企业CA保存在该目录下。

接下来检查是否安装成功;

cd /d %JAVA_HOME%\jre\lib\security

keytool -list -V -keystore cacerts -storepass changeit | findstr /n xxxrootca

keytool -list -V -keystore cacerts -storepass changeit | findstr /n xxxenterpriseca1

linux环境

输入linux命令;

cd $JAVA_HOME/jre/lib/security

wget --no-check-certificate https://xxx/artifactory/CMC-Release/certificates/xxxRootCA.cer

wget --no-check-certificate https://xxx/artifactory/CMC-Release/certificates/xxxEnterpriseCA1.cer

keytool -keystore cacerts -importcert -alias xxxRootCA -file xxxRootCA.cer -storepass changeit -noprompt

keytool -keystore cacerts -importcert -alias xxxEnterpriseCA1 -file xxxEnterpriseCA1.cer -storepass changeit -noprompt

chmod 755 -R $JAVA_HOME/jre/lib/security/cacerts

检查是否安装成功;

cd $JAVA_HOME/jre/lib/security

keytool -list -V -keystore cacerts -storepass changeit | grep -i xxxRootCA

keytool -list -V -keystore cacerts -storepass changeit | grep -i xxxEnterpriseCA1

参考链接:
1、command line tool and library for transferring data with URLs
2、github_curl
3、PHP网络爬虫之CURL
4、curl命令 在线中文手册

你可能感兴趣的:(CA)