{"id":550,"date":"2023-02-25T17:48:58","date_gmt":"2023-02-25T09:48:58","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=550"},"modified":"2023-04-29T20:37:38","modified_gmt":"2023-04-29T12:37:38","slug":"curl-uses-ssl-certificate-to-access-https","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/25\/curl-uses-ssl-certificate-to-access-https\/","title":{"rendered":"CURL\u4f7f\u7528SSL\u8bc1\u4e66\u8bbf\u95eeHTTPS"},"content":{"rendered":"<h2>\u8bc1\u4e66\u683c\u5f0f\u8f6c\u6362<\/h2>\n<p>\u82e5\u670d\u52a1\u7aef\u8981\u6c42\u5ba2\u6237\u7aef\u8ba4\u8bc1\uff0c\u9700\u8981\u5c06pfx\u8bc1\u4e66\u8f6c\u6362\u6210pem\u683c\u5f0f<\/p>\n<pre><code class=\"language-bash\">openssl pkcs12 -clcerts -nokeys -in cert.pfx -out client.pem    #\u5ba2\u6237\u7aef\u4e2a\u4eba\u8bc1\u4e66\u7684\u516c\u94a5  \n\nopenssl pkcs12 -nocerts -nodes -in cert.pfx -out key.pem    #\u5ba2\u6237\u7aef\u4e2a\u4eba\u8bc1\u4e66\u7684\u79c1\u94a5<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u4e5f\u53ef\u4ee5\u8f6c\u6362\u4e3a\u516c\u94a5\u4e0e\u79c1\u94a5\u5408\u4e8c\u4e3a\u4e00\u7684\u6587\u4ef6<\/p>\n<pre><code class=\"language-bash\">openssl pkcs12 -in cert.pfx -out all.pem -nodes    #\u5ba2\u6237\u7aef\u516c\u94a5\u4e0e\u79c1\u94a5\uff0c\u4e00\u8d77\u5b58\u5728all.pem\u4e2d<\/code><\/pre>\n<h2>\u6267\u884ccurl\u547d\u4ee4<\/h2>\n<p>\uff081\uff09\u4f7f\u7528<code>client.pem<\/code> + <code>key.pem<\/code><\/p>\n<pre><code class=\"language-bash\">curl -k --cert client.pem --key key.pem https:\/\/www.xxxx.com<\/code><\/pre>\n<p>\uff082\uff09\u4f7f\u7528<code>all.pem<\/code><\/p>\n<pre><code class=\"language-bash\">curl -k --cert all.pem https:\/\/www.xxxx.com<\/code><\/pre>\n<p>\u4f7f\u7528<code>-k<\/code>\uff0c\u662f\u4e0d\u5bf9\u670d\u52a1\u5668\u7684\u8bc1\u4e66\u8fdb\u884c\u68c0\u67e5\uff0c\u8fd9\u6837\u5c31\u4e0d\u5fc5\u5173\u5fc3\u670d\u52a1\u5668\u8bc1\u4e66\u7684\u5bfc\u51fa\u95ee\u9898\u3002<\/p>\n<pre><code>curl -d &#039;@wxpay_refund.txt&#039; --cacert rootca.pem  -k --cert .\/apiclient_cert.pem --key apiclient_key.pem https:\/\/api.mch.weixin.qq.com\/secapi\/pay\/refund<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8bc1\u4e66\u683c\u5f0f\u8f6c\u6362 \u82e5\u670d\u52a1\u7aef\u8981\u6c42\u5ba2\u6237\u7aef\u8ba4\u8bc1\uff0c\u9700\u8981\u5c06pfx\u8bc1\u4e66\u8f6c\u6362\u6210pem\u683c\u5f0f openssl pkcs12 -clc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[97],"tags":[73],"class_list":["post-550","post","type-post","status-publish","format-standard","hentry","category-tools-skills","tag-curl"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=550"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/550\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}