繁体   English   中英

使用python从自定义路径验证SSL证书

[英]Verify SSL certificate from the custom path using python

我已经安装了Apache Web服务器。 为apache网站生成了SSL。 得到了证书文件和密钥。 我写了一个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扩展字段中拥有名为hostAlternativeNames的所有主机名和IP。 您遵循的说明可能已过时。

这是使用OpenSSL做到这一点的平庸指南

https://support.citrix.com/article/CTX135602

如果要签名某些IP地址,则字段名是IP.1而不是DNS.1如上面的链接中所示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM