Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt "no subjectaltname" test for service-identitity >= 24 #452

Merged
merged 1 commit into from
Jan 14, 2024

Conversation

jlaine
Copy link
Contributor

@jlaine jlaine commented Jan 14, 2024

When a certificate contains no subjectAltName extension, service-identity now raises a CertificateError instead of a VerificationError.

When a certificate contains no subjectAltName extension,
`service-identity` now raises a `CertificateError` instead of a
`VerificationError`.
@jlaine
Copy link
Contributor Author

jlaine commented Jan 14, 2024

@rthalley I'm not entirely comfortable with this code, because extract_patterns could also raise an Exception.

I think I'd be more comfortable with exactly two errors paths:

  • CertificateError => use str(exc)
  • VerificationError => f"Certificate subjectAltName does not match {hostname}."

Copy link

codecov bot commented Jan 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (20cd4ee) 100.00% compared to head (9dd2b96) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #452   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         4881      4881           
=========================================
  Hits          4881      4881           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rthalley
Copy link
Contributor

You could also go for "belt and braces" and just fall back to the first exception if extract_patterns raises, e.g.

try:
    patterns = service_identity.cryptography.extract_patterns(certificate)
except Exception:
    patterns = []
if len(patterns) == 0:
     errmsg = str(exc)

@jlaine
Copy link
Contributor Author

jlaine commented Jan 14, 2024

I'm going to merge as-is after thinking about it, we can always revisit this.

@jlaine jlaine merged commit e899593 into aiortc:main Jan 14, 2024
29 checks passed
@jlaine jlaine deleted the service-identity-update branch January 23, 2024 12:40
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