Fix check_ssl_cert_expire on newer pyOpenSSL#372
Open
TuxPowered42 wants to merge 1 commit into
Open
Conversation
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.
There was a problem hiding this comment.
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) withcryptography’sSUBJECT_ALTERNATIVE_NAMEparsing. - Replace CN extraction (
get_subject/get_components) withcryptographysubject 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pyOpenSSL 26.2.0 removed the deprecated X509Extension API (get_extension/get_extension_count), which broke SAN extraction with:
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.