前置条件

配置Java环境变量。

具体操作

windows环境

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

cd /d %JAVA_HOME%\jre\lib\securitycurl -kv https://xxx/artifactory/CMC-Release/certificates/xxxRootCA.cer -o xxxRootCA.cercurl -kv https://xxx/artifactory/CMC-Release/certificates/xxxEnterpriseCA1.cer -o xxxEnterpriseCA1.cerkeytool -keystore cacerts -importcert -alias xxxRootCA -file xxxRootCA.cer -storepass changeit -nopromptkeytool -keystore cacerts -importcert -alias xxxEnterpriseCA1 -file xxxEnterpriseCA1.cer -storepass changeit -noprompt

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

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

cd /d %JAVA_HOME%\jre\lib\securitykeytool -list -V -keystore cacerts -storepass changeit | findstr /n xxxrootcakeytool -list -V -keystore cacerts -storepass changeit | findstr /n xxxenterpriseca1

linux环境

输入linux命令;

cd $JAVA_HOME/jre/lib/securitywget --no-check-certificate https://xxx/artifactory/CMC-Release/certificates/xxxRootCA.cerwget --no-check-certificate https://xxx/artifactory/CMC-Release/certificates/xxxEnterpriseCA1.cerkeytool -keystore cacerts -importcert -alias xxxRootCA -file xxxRootCA.cer -storepass changeit -nopromptkeytool -keystore cacerts -importcert -alias xxxEnterpriseCA1 -file xxxEnterpriseCA1.cer -storepass changeit -nopromptchmod 755 -R $JAVA_HOME/jre/lib/security/cacerts

检查是否安装成功;

cd $JAVA_HOME/jre/lib/securitykeytool -list -V -keystore cacerts -storepass changeit | grep -i xxxRootCAkeytool -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命令 在线中文手册