when someone abandons you,it is him that gets loss because he lost someone who truly loves him but you just lost one who doesn’t love you.
受制于人最大的坏处就是处处落后一步,凡事都只能见招拆招
这不,实验室订阅系统更新了,更换了 url 不说,还改成了 https 协议,免不了增加证书,旧时 requests 访问直接不可用
趁这个机会,也复习了一下 requests 关于 ca 证书的一个使用
背景知识:当前 requests 会默认使用 certifi 包里的证书
1 | # utils.py |
问题 1: certifi 包的证书路径在哪儿?
1 | import certifi |
问题 2: requests 包的默认证书路径是哪儿?
1 | from requests.utils import DEFAULT_CA_BUNDLE_PATH |
问题 3: 将自有证书更新到默认证书文件,以便 requests 调用?
1 | $ cp /path/to/crt_name /usr/local/share/ca-certificates/ |
问题 4: 想从默认证书文件中删除自有证书?
1 | $ rm -f /usr/local/share/ca-certificates/crt_name |
其实即使不将自有证书加入到系统证书文件中,也是可以让 requests 调用的
1 | requests.get(url=url, verify='/path/to/crt_name') |
be slow to promise and quick to perform.