我已经安装了 apache 网络服务器。为 apache 网站生成的 SSL。获得了证书文件和 key 。我写了一个 python 片段来验证网站的 ssl 文件。证书文件路径存放在 cer_auth 中。我的代码将访问 cer_auth 中的文件,对其进行验证并提供结果。但它显示错误。如何解决?
代码如下:
import requests
host = '192.168.1.27'
host1 = 'https://'+host
#cer_auth = '/etc/ssl/certs/ca-certificates.crt'
cer_auth = '/home/paulsteven/Apache_SSL/apache-selfsigned.crt'
print(host1)
try:
requests.get(host1, verify= cer_auth)
print("SSL Certificate Verified")
except:
print("No SSL certificate")
我得到的错误:
https://192.168.1.27
/home/paulsteven/.local/lib/python3.5/site-packages/urllib3/connection.py:362: SubjectAltNameWarning: Certificate for 192.168.1.27 has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
SubjectAltNameWarning
No SSL certificate
最佳答案
将证书指向主机名的旧方法是通过 CommonName 或 CN
字段。由于浏览器处理证书的方式发生变化,这种做法正在迅速发生变化。目前的期望是将证书中的 x509v3 扩展字段中的所有主机名和 IP 命名为 subjectAlternativeNames。您遵循的说明可能已过时。
这是一个关于使用 OpenSSL 做到这一点的平庸指南
https://support.citrix.com/article/CTX135602
如果您想为某些 IP 地址签名,字段名称是 IP.1
而不是上面链接中的 DNS.1
。
关于python - 使用 python 从自定义路径验证 SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54807151/