Getting certificate chain with Python 3.3 SSL module

后端 未结 3 866
萌比男神i
萌比男神i 2021-01-12 04:53

I can get the standard certificate information for an SSL connection in Python 3.3 via the getpeercert() method on the SSL socket. However, it doesn\'t seem to provide the c

3条回答
  •  孤街浪徒
    2021-01-12 05:41

    I'm not sure, but I think that part of the OpenSSL API just isn't available in Python's ssl-module.

    It seems that the function SSL_get_peer_cert_chain is used to access the certificate chain in OpenSSL. See, for example, the section of openssl s_client that prints the output you included. On the other hand, grepping the source of Python's ssl-module for SSL_get_peer_cert_chain yields no matches.

    M2Crypto and pyOpenSSL both seem to include a get_peer_cert_chain function, if you're willing to look at other (and non-stdlib) libraries. I can't vouch for them personally, though, since I haven't used them much.

提交回复
热议问题