CURL使用SSL证书访问HTTPS

证书格式转换

若服务端要求客户端认证,需要将pfx证书转换成pem格式

openssl pkcs12 -clcerts -nokeys -in cert.pfx -out client.pem    #客户端个人证书的公钥  

openssl pkcs12 -nocerts -nodes -in cert.pfx -out key.pem    #客户端个人证书的私钥

也可以转换为公钥与私钥合二为一的文件

openssl pkcs12 -in cert.pfx -out all.pem -nodes    #客户端公钥与私钥,一起存在all.pem中

执行curl命令

(1)使用client.pem + key.pem

curl -k --cert client.pem --key key.pem https://www.xxxx.com

(2)使用all.pem

curl -k --cert all.pem https://www.xxxx.com

使用-k,是不对服务器的证书进行检查,这样就不必关心服务器证书的导出问题。

curl -d '@wxpay_refund.txt' --cacert rootca.pem  -k --cert ./apiclient_cert.pem --key apiclient_key.pem https://api.mch.weixin.qq.com/secapi/pay/refund
上一篇 jks转pem
下一篇 quartz Cron表达式
目录
文章列表
1 Android上使用Tesseract识别文字
Android上使用Tesseract识别文字
2
Kubernetes ingress方式访问集群服务
Kubernetes ingress方式访问集群服务
3
WordPress及WooCommerce安装
WordPress及WooCommerce安装
4
Druid连接池加密与解密
Druid连接池加密与解密
5
微服务网关 Spring Cloud Gateway 进阶
微服务网关 Spring Cloud Gateway 进阶
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。