How do I create and sign certificates with Python's pyOpenSSL?

社会主义新天地 提交于 2019-12-03 08:33:15

You are setting notBefore and notAfter after you already signed the certificate and thus change the already signed certificate - which makes the signature not match the certificate anymore:

client_cert.sign(ca_key, 'sha256')  

client_cert.gmtime_adj_notBefore(0)
client_cert.gmtime_adj_notAfter(10*365*24*60*60)

# Save certificate
...

If you move the signing part to be the last step, i.e. directly before writing the file, then the verification will be successful:

client_cert.gmtime_adj_notBefore(0)
client_cert.gmtime_adj_notAfter(10*365*24*60*60)

client_cert.sign(ca_key, 'sha256')  

# Save certificate
...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!