cryptography icon indicating copy to clipboard operation
cryptography copied to clipboard

WIP: Add method Certificate._has_signature_of()

Open KonstantinShemyak opened this issue 3 years ago • 9 comments

This PR is the first step in implementing #5116 . Here, we only check the validity of the cryptographic signature. As this method is likely to be used only inside Certificate.is_issued_by(), it is declared as internal. Huge line diff is caused by added test certificates, real code change is small.

KonstantinShemyak avatar Apr 02 '21 09:04 KonstantinShemyak

CI step pyca/check has been stuck for two days 🤔

KonstantinShemyak avatar Apr 04 '21 13:04 KonstantinShemyak

Yes, it's a known issue. For now there's nothing to do but ignore that one job.

alex avatar Apr 04 '21 14:04 alex

Now I think that it would be more appropriate to move this method under x509.base.Certificate? The method has nothing specific to OpenSSL and it will be equally well used by any other possible backend. Unless someone (@reaperhulk ?) has something to confront in this reasoning, I'll do the next version with the move.

KonstantinShemyak avatar Apr 12 '21 20:04 KonstantinShemyak

Force-push: implemented suggestion to assert type.

KonstantinShemyak avatar Apr 13 '21 05:04 KonstantinShemyak

Force-push: the new method is implemented completely under x509; no new code under hazmat anymore.

To remind, the final goal of this work is to implement certificate validation (#2381). This PR is the first step out of three. The second step is #5116, I have pushed a WIP branch (missing tests and documentation) showing how I plan to do it. The final step is doing checks as in #5116 along all computed chains of trust from the leaf to any of the provided trusted CAs.

GitHub seems to start requiring approval from project maintainers to run workflows :smiling_imp:

KonstantinShemyak avatar May 29 '21 20:05 KonstantinShemyak

Force-push: rebase on updated main.

KonstantinShemyak avatar May 31 '21 17:05 KonstantinShemyak

^ rebase on updated main.

@reaperhulk , @alex - what is your view on this approach? While this is only first step out of three, I believe it's also useful by itself, as now the user of the library needs non-trivial code to just verify the cryptographic part of the signature.

KonstantinShemyak avatar Jun 09 '21 13:06 KonstantinShemyak

First, I'm sorry we haven't given this PR much attention.

Second, I think I'm conceptually ok with this, but I'm on the fence about having it as a private method. I realize the goal is for it to be ultimately used by a more powerful (and safe) public API, but I do wonder if this shouldn't just be public as well.

I haven't reviewed the implementation of the PR yet. I also think we might want to iterate on the name a bit.

alex avatar Jun 10 '21 14:06 alex

Branch updated on main. I'm 100% happy with making the method public and naming it in any way; the goal is to get the certificate validation :slightly_smiling_face:

KonstantinShemyak avatar Jun 10 '21 19:06 KonstantinShemyak

https://github.com/pyca/cryptography/commit/db7dd61de3c6f7c8d66d5615cbfbcf5c085c4448 incorporates this

alex avatar Jan 13 '23 04:01 alex