How can I decode a SSL certificate using python?

前端 未结 5 1918
半阙折子戏
半阙折子戏 2020-12-02 14:42

How can I decode a pem-encoded (base64) certificate with Python? For example this here from github.com:

-----BEGIN CERTIFICATE-----
MIIHKjCCBhKgAwIBAgIQDnd2i         


        
5条回答
  •  萌比男神i
    2020-12-02 15:02

    I am not Sure how you received it but another simple way for getting it installed is to just write it as a binary file and then run it using os

    import os
    
    cert= function_gives_binary_cert()
    with open('RecvdCert.der','wb') as file:
         file.write(cert)
    
    os.startfile('RecvdCert.der')
    

    Beware of running received binary from an unknown source. Just want to decode then use OpenSSL as mentioned in other answers.

提交回复
热议问题