Skip to content

Fix check_ssl_cert_expire on newer pyOpenSSL#372

Open
TuxPowered42 wants to merge 1 commit into
masterfrom
heck_ssl_cert_expire
Open

Fix check_ssl_cert_expire on newer pyOpenSSL#372
TuxPowered42 wants to merge 1 commit into
masterfrom
heck_ssl_cert_expire

Conversation

@TuxPowered42

Copy link
Copy Markdown
Contributor

pyOpenSSL 26.2.0 removed the deprecated X509Extension API (get_extension/get_extension_count), which broke SAN extraction with:

AttributeError: 'X509' object has no attribute 'get_extension'

Read the subjectAltName via cert.to_cryptography() instead, iterating the extension's DNSName/IPAddress entries directly.

While here, migrate get_issued_to() off get_subject()/get_components(), both deprecated in pyOpenSSL 26.3.0 and on the same removal path, to cert.to_cryptography().subject.

cryptography is already a pyOpenSSL dependency, so no new requirement is introduced. get_notAfter() and load_certificate() are left as-is; they are not deprecated.

pyOpenSSL 26.2.0 removed the deprecated X509Extension API
(get_extension/get_extension_count), which broke SAN extraction with:

    AttributeError: 'X509' object has no attribute 'get_extension'

Read the subjectAltName via cert.to_cryptography() instead, iterating the
extension's DNSName/IPAddress entries directly.

While here, migrate get_issued_to() off get_subject()/get_components(), both
deprecated in pyOpenSSL 26.3.0 and on the same removal path, to
cert.to_cryptography().subject.

cryptography is already a pyOpenSSL dependency, so no new requirement is
introduced. get_notAfter() and load_certificate() are left as-is; they are
not deprecated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates check_ssl_cert_expire to restore compatibility with newer pyOpenSSL releases by moving certificate SAN and subject parsing onto cryptography via cert.to_cryptography(), avoiding removed/deprecated pyOpenSSL X509 APIs.

Changes:

  • Replace SAN extraction (get_extension_count/get_extension) with cryptography’s SUBJECT_ALTERNATIVE_NAME parsing.
  • Replace CN extraction (get_subject/get_components) with cryptography subject attribute access.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 150 to +151
cert_domains = {get_issued_to(cert)}
for alt_domain in decode_san(get_extension_value(cert, b'subjectAltName')):
cert_domains.add(alt_domain)
cert_domains.update(get_san(cert))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants