{"id":99817,"date":"2020-04-22T23:23:17","date_gmt":"2020-04-22T15:23:17","guid":{"rendered":"http:\/\/4563.org\/?p=99817"},"modified":"2020-04-22T23:23:17","modified_gmt":"2020-04-22T15:23:17","slug":"upyun-%e6%b2%a1%e6%8f%90%e4%be%9b-https-%e8%af%81%e4%b9%a6%e6%9b%b4%e6%96%b0%e7%9a%84-api-%e4%b8%8d%e5%a6%82%e8%87%aa%e5%b7%b1%e5%86%99%e4%b8%80%e4%b8%aa%ef%bc%88%e4%bb%a5%e5%8f%8a%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=99817","title":{"rendered":"upyun \u6ca1\u63d0\u4f9b https \u8bc1\u4e66\u66f4\u65b0\u7684 API \u4e0d\u5982\u81ea\u5df1\u5199\u4e00\u4e2a\uff08\u4ee5\u53ca\u65e5\u5fd7\u4e0b\u8f7d\uff09"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  upyun \u6ca1\u63d0\u4f9b https \u8bc1\u4e66\u66f4\u65b0\u7684 API \u4e0d\u5982\u81ea\u5df1\u5199\u4e00\u4e2a\uff08\u4ee5\u53ca\u65e5\u5fd7\u4e0b\u8f7d\uff09               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cy97cool <\/span>  <span><i><\/i> 61<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>https:\/\/github.com\/zjuchenyuan\/EasyLogin\/blob\/master\/examples\/upyun\/upyun.py<\/p>\n<p>\u57fa\u4e8e\u6211\u7684 EasyLogin \u5199\u7684\uff0c\u5176\u5b9e\u5c31\u662f\u5c01\u88c5\u4e86\u4e00\u4e0b requests \u548c Beautifulsoup\uff0c\u63d0\u4f9b\u4e86 cookie \u4fdd\u5b58\u548c\u5185\u5bb9\u7f13\u5b58\u673a\u5236<\/p>\n<p>\u8fd9\u4e2a upyun.py \u4f1a\u767b\u5f55 console.upyun.com \uff0c\u63d0\u4f9b\u89c4\u5219\u5237\u65b0\u548c https \u8bc1\u4e66\u66f4\u65b0\u529f\u80fd\uff0c\u7528\u6cd5\u5982<\/p>\n<pre><code># \u8fd9\u91cc\u7684 @\u4f1a\u88ab\u66ff\u6362\u6210*\uff0c \u5237\u65b0 https:\/\/py3.io\/*.html \u7684\u7f13\u5b58 python3 upyun.py purge https:\/\/py3.io\/@.html  # \u67e5\u770b\u6240\u6709\u8bc1\u4e66\uff0c\u53ea\u663e\u793a\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u81ea\u6709\u8bc1\u4e66+\u6b63\u5728\u4f7f\u7528\u7684\u5df2\u7ecf\u8fc7\u671f\u7684\u8bc1\u4e66 python3 upyun.py https list  # \u66f4\u65b0\u6240\u6709 30 \u5929\u4e4b\u5185\u8fc7\u671f\u7684\u8bc1\u4e66 python3 upyun.py https renew <\/code><\/pre>\n<p>\u66f4\u65b0\u8bc1\u4e66\u9664\u4e86\u9700\u8981\u5728 config.py \u4e2d\u63d0\u4f9b\u767b\u5f55\u7684<code>USERNAME<\/code>\u548c<code>PASSWORD<\/code>\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u63d0\u4f9b\u4e00\u4e2a api_func(domain_name)\u51fd\u6570\uff0c\u8fd9\u4e2a\u51fd\u6570\u9700\u8981\u8fd4\u56de\u8bc1\u4e66\u4fe1\u606f<\/p>\n<pre><code> {\"certificate\":\"-----BEGIN CERTIFICATE-----n...\",    \"private_key\":\"-----BEGIN RSA PRIVATE KEY-----n...\"} <\/code><\/pre>\n<p>\u6211\u662f\u4f7f\u7528\u51fd\u6570\u8ba1\u7b97\u7528 dns \u9a8c\u8bc1\u81ea\u52a8\u66f4\u65b0\u8bc1\u4e66\uff1a https:\/\/py3.io\/Nginx\/#https_1<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u5c31\u662f\u8fd9\u4e2a\u6837\u5b50\uff1a(\u6ce8\u610f\u5230\u4f20\u5165\u7684\u57df\u540d\u53ef\u80fd\u662f\u5b50\u57df\u540d \u9700\u8981\u5224\u65ad\u540e\u7f00\uff09<\/p>\n<pre><code>def renew_api(domain):     namedict = {       'py3.io': 'py3io_ATxx',      }     for k, v in namedict.items():         if domain.endswith(k):             return get_from_oss(v)     return False  import requests sess = requests.session() def get_from_oss(name):     crt = sess.get(\"https:\/\/OSSNAME.oss-cn-REGION.aliyuncs.com\/{name}.crt\".format(name=name), headers={\"Referer\":\"Referer_STRING\"})     key = sess.get(\"https:\/\/OSSNAME.oss-cn-REGION.aliyuncs.com\/{name}.key\".format(name=name), headers={\"Referer\":\"Referer_STRING\"})     return {\"certificate\": crt.text, \"private_key\": key.text} <\/code><\/pre>\n<p>\u53e6\u5916 upyun \u771f\u7684\u4f1a\u5728 30 \u5929\u5220\u8bbf\u95ee\u65e5\u5fd7\uff0c\u7136\u800c\u6cd5\u5f8b\u8981\u6c42\u81f3\u5c11\u4fdd\u7559\u516d\u4e2a\u6708\u2511(\uffe3\u0414 \uffe3)\u250d \u6240\u4ee5\u9700\u8981\u81ea\u5df1\u4e0b\u8f7d\u65e5\u5fd7\u54af\uff1a https:\/\/github.com\/zjuchenyuan\/EasyLogin\/blob\/master\/examples\/upyun\/downloadlogs.py<\/p>\n<p>\u4ece config.py \u8bfb\u53d6 mydomains\uff0c\u8c03\u7528 upyun \u63d0\u4f9b\u7684 openapi \u83b7\u53d6\u65e5\u5fd7\u5e76\u4e0b\u8f7d<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>upyun \u6ca1\u63d0\u4f9b https \u8bc1&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/99817"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=99817"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/99817\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=99817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=99817"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=99817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}