-
Notifications
You must be signed in to change notification settings - Fork 56
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
Maintain context for key usage mismatch errors #337
base: main
Are you sure you want to change the base?
Conversation
88559a5
to
ff5f073
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #337 +/- ##
==========================================
- Coverage 97.76% 97.55% -0.22%
==========================================
Files 20 20
Lines 4343 4369 +26
==========================================
+ Hits 4246 4262 +16
- Misses 97 107 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
/// | ||
/// The contents of this type depend on whether the `alloc` feature is enabled. | ||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct RequiredEkuNotFoundContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fiddled with this a fair bunch. The challenge here is that most of the internals of KeyUsage
are private API.
KeyUsage
(the public API surface) also represents theRequired
vsRequiredIfPresent
dichotomy, which is relevant forrequired
but not forpresent
so much.- Internally we currently use
KeyPurposeId
which uses an internalInput
(which means the only way to make it'static
is with a '&static [u8]
which isn't feasible here). - We might want to represent
EKU_CLIENT_AUTH
andEKU_SERVER_AUTH
in a way that are actually usable with the public API, which isKeyUsage::client_auth()
andKeyUsage::server_auth()
, and represent other OIDs in a somewhat readable representation.
let err = check_cert(ee, ca).unwrap_err(); | ||
assert_eq!( | ||
err, | ||
webpki::Error::RequiredEkuNotFoundContext(RequiredEkuNotFoundContext { | ||
required: KeyUsage::client_auth(), | ||
present: vec![vec![43, 6, 1, 5, 5, 7, 3, 1]], | ||
}) | ||
); | ||
|
||
assert_eq!( | ||
format!("{err}"), | ||
"RequiredEkuNotFoundContext(RequiredEkuNotFoundContext { required: KeyUsage { inner: RequiredIfPresent(KeyPurposeId { oid_value: Input }) }, present: [[43, 6, 1, 5, 5, 7, 3, 1]] })" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes need to be made in the Python test generator code. Right now CI is flagging the diff that results from regenerating.
@@ -141,8 +143,13 @@ pub enum Error { | |||
|
|||
/// The certificate is not valid for the Extended Key Usage for which it is | |||
/// being validated. | |||
#[deprecated(since = "0.103.2", note = "use RequiredEkuNotFoundContext instead")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a Cargo.toml
commit to the branch that bumps the version to 0.103.2 ?
@@ -485,18 +501,38 @@ impl ExtendedKeyUsage { | |||
let input = match (input, self) { | |||
(Some(input), _) => input, | |||
(None, Self::RequiredIfPresent(_)) => return Ok(()), | |||
(None, Self::Required(_)) => return Err(Error::RequiredEkuNotFound), | |||
(None, Self::Required(_)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
codecov is flagging missing coverage for L505..512 - that seems worth having IMO.
I think we should probably figure out the rustls part of this before we merge/release it. |
No description provided.