使用python验证来自自定义路径的SSL证书
我已经安装了ApacheWeb服务器。为apache网站生成SSL。已获取证书文件和密钥。我编写了一个python代码片段来验证网站的ssl文件。证书文件路径存储在cer_auth中。我的代码将访问ceru auth中的文件,验证它并提供结果。但它显示出错误。如何解决 代码如下:使用python验证来自自定义路径的SSL证书,python,ssl,python-requests,Python,Ssl,Python Requests,我已经安装了ApacheWeb服务器。为apache网站生成SSL。已获取证书文件和密钥。我编写了一个python代码片段来验证网站的ssl文件。证书文件路径存储在cer_auth中。我的代码将访问ceru auth中的文件,验证它并提供结果。但它显示出错误。如何解决 代码如下: import requests host = '192.168.1.27' host1 = 'https://'+host #cer_auth = '/etc/ssl/certs/ca-certificates.crt
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实现这一点的平庸指南
如果您想为某些IP地址签名,字段名是IP.1
,而不是上面链接中的DNS.1