-
Notifications
You must be signed in to change notification settings - Fork 0
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
tests: Add x509-limbo
test
#1
Conversation
At the moment, If I temporarily modify the testcase in the
I'll work on debugging these issues and work on getting some fixes in. |
tests/x509/test_verification.py
Outdated
for testcase in testcases: | ||
_limbo_testcase(testcase) |
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 think we want to use the subtests
fixture here, with subtests.test()
as a context manager to provide distinct subtests for each of these testcases.
Example from another unit test:
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.
Ah, I was looking for something like that. Will do that now.
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.
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.
This doesn't seem to work (at least now how I was expecting). Even in the test_name.py
example, if I place an assert False
within the subtest, I only see one test failure.
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.
Yeah, that's surprising (although I admittedly don't know subtests too well). Maybe @reaperhulk or @alex has ideas here 🙂
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.
Hahahha, funny story: So the behavior of the upstream pytest-subtests
does kind of what you'd expect: runs them all.
We have our own custom version that only runs one, and this is because of performance (not the performance of running the tests, but rather the overhead of the subtest machinery itself): https://github.com/pyca/cryptography/blob/main/tests/conftest.py#L52
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.
Ah, gotcha -- so your custom version fails fast on the first failure, and only runs them all if they all pass?
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.
Correct. It's advantage over just having the loop is handling skips correctly. (Also that it's API compatible with proper subtests so if they're ever faster, we can switch back)
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.
Makes sense, thanks for explaining!
Segfault in |
NB: We still need to debug that segfault, but from a previous conversation with @tetsuo-cpp and @reaperhulk: the In other words: we should debug here first, then flip that testcase's expected result (should succeed, not fail). |
I've been looking into this segfault but haven't quite figured it out yet. As we discussed, it seems to be coming from this line. However, this code looks functionally identical to So I'd have expected that if I call |
I've put together a list of failing Limbo tests + some commentary on whether I think they're legitimate failures or not:
To summarise, we need to: populate the peer name in the testcase and begin supporting the key usage extension in Limbo (I believe it's in the spec but we don't use it yet). (C2SP/x509-limbo#35)
|
Yeah, this is an incredibly annoying one: technically path validation should reject wildcards on "public suffixes" as a matter of policy, but this makes validation dependent on either (1) an online service, or (2) a possibly stale pre-baked list of public suffixes. I'm pretty sure this is why neither OpenSSL nor Go bothers with this check, so perhaps we should give it some kind of "pedantic" marker and explicitly skip it.
Yeah, this is almost certainly a missing check.
This one points to an error that needs to be corrected in our API: we conflate the terms "leaf", "EE", and "non-CA cert" when in reality a leaf in a chain doesn't have to be an EE (it can be a CA). In other words: we really need a
We can probably treat a lot of these as skips for the initial MVP (especially the distinguished name ones). We should definitely support DNS name constraints, though. |
de853c3
to
69eb9a1
Compare
c871a00
to
658237d
Compare
04d41a8
to
4c96b6e
Compare
tests: Use subtests in `test_limbo` Use the correct peer name types tests: Flip the Limbo validation kind to `SERVER`
4c96b6e
to
0a6dfa5
Compare
@woodruffw This is up-to-date and passing now. Provided that we're happy with pyca#47, we should be able to merge this. |
@@ -236,6 +236,7 @@ where | |||
&self, | |||
working_cert: &'a Certificate<'work>, | |||
current_depth: u8, | |||
is_leaf: bool, |
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.
Rather than a new is_leaf
state, maybe check current_depth == 1
? Unless I'm missing something.
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.
The reason I can't do this is that self-issued certificates don't increase the depth. So if current_depth == 1
, we don't know whether that's actually the leaf certificate or the previous certificate just happened to be self-issued.
I'll leave a comment to that effect.
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.
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.
Ah yeah, that's a pain. I think is_leaf
is pretty ugly here, but I can't think of a better way to do this.
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.
Yeah... definitely not ideal.
const RFC5280_CRITICAL_CA_EXTENSIONS: &[asn1::ObjectIdentifier] = | ||
&[BASIC_CONSTRAINTS_OID, KEY_USAGE_OID]; | ||
&[BASIC_CONSTRAINTS_OID, KEY_USAGE_OID, NAME_CONSTRAINTS_OID]; | ||
const RFC5280_CRITICAL_EE_EXTENSIONS: &[asn1::ObjectIdentifier] = &[ | ||
BASIC_CONSTRAINTS_OID, | ||
SUBJECT_ALTERNATIVE_NAME_OID, |
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 need to remove these, now that we have discrete extension policy APIs 🙂
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 can make a PR for that. 👍
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.
Thanks! I think the "right" way to do this is to iterate through all of the extensions in permits_basic
and fail if any critical extensions are not covered by an extension policy (whether basic, EE, or CA).
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.
Yep! Sounds good.
Thanks, this is looking really good! I left a couple of Qs on C2SP/x509-limbo#47. |
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.
LGTM!
@tetsuo-cpp does limbo.json
need to be updated again, now that we've merged C2SP/x509-limbo#47?
Should be good to go! The |
Excellent! Merging. |
No description provided.