'Python ssl module error: AttributeError: module 'ssl' has no attribute 'enum_certificates'

I'm trying to use python to list the installed certificates installed in my machine. I'm using python 3.6.8. I'm using the code below. It works in Windows, but fails in CentOS:

import ssl
from cryptography import x509

for store in ["CA", "ROOT", "MY"]:
    for cert, encoding, trust in ssl.enum_certificates(store):
        certificate = x509.load_der_x509_certificate(cert, backend=None)
        print(certificate.issuer, certificate.not_valid_after)

The CentOS error is:

AttributeError: module 'ssl' has no attribute 'enum_certificates'

It is weird because the docs of ssl modules say that the enum_certificates method was added in version 3.4. It should be present.

How would I list the installed certificates?



Solution 1:[1]

The enum_certificates attribute in only available on Windows. In you link, just above where it says New in version 3.4. it says Availability: Windows.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nick Lauder