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

Verify Certificate Chain Without Trust Store #12359

Closed
Wyko opened this issue Jan 29, 2025 · 9 comments
Closed

Verify Certificate Chain Without Trust Store #12359

Wyko opened this issue Jan 29, 2025 · 9 comments
Labels
Stale waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply.

Comments

@Wyko
Copy link

Wyko commented Jan 29, 2025

Good morning!

I have an application that needs to verify a certificate chain, ignoring the trustworthiness of the root. Specifically, I need to do the following:

  • Given a specific URL;
  • Download the certificate;
  • Check that the server / leaf certificate is present;
  • Verify that it is signed by any root CA
  • Verify that the full chain up to and including the Intermediates and the CA is present in the chain

The solutions I have found rely on the trust store of my computer to already contain the relevant root CAs. Can the package help me here?

@alex
Copy link
Member

alex commented Jan 29, 2025

Why do you want to accomplish this? Verifying a certificate chains to any root CA provides no security properties, simply return True is a valid implementation.

@alex alex added the waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply. label Jan 29, 2025
@Wyko
Copy link
Author

Wyko commented Jan 29, 2025

@alex , this isn't about security, actually. This is about basic validation of a configuration on a network device. For this configuration type, clients provide their own certificates which must be signed by a root CA somewhere. I don't need to (nor am I even able to) validate that the root CA is valid or trusted; I only need to validate that the leaf certificate is signed and that the file contains a complete chain back to whatever root signed it.

I know it's not exactly common use case, but it's what I'm working with right now.

@alex
Copy link
Member

alex commented Jan 29, 2025 via email

@Wyko
Copy link
Author

Wyko commented Jan 29, 2025

The second one. As I put in my original post, once I have everything installed on my network device, I should be able to access it in my browser, like this:

echo "q" | openssl s_client -connect microsoft.com:443 -showcerts | grep depth

This should show the entire chain. Sometimes, if a cert is misconfigured, it could be missing one of the certificates in the chain:

echo "q" | openssl s_client -connect incomplete-chain.badssl.com:443 -showcerts | grep depth

I need to diagnose these types of errors in my python validation tool.

@alex
Copy link
Member

alex commented Jan 29, 2025 via email

@Wyko
Copy link
Author

Wyko commented Jan 30, 2025

Okay, fair enough. Is there a way to get the intermediates using Cryptography? So far I've seen this:
leaf = load_pem_x509_certificate(ssl.get_server_certificate((subject, 443)).encode())
But as far as I can tell, that only returns the leaf, and not whatever intermediates the server might also be presenting.

@alex
Copy link
Member

alex commented Jan 30, 2025 via email

Copy link

github-actions bot commented Feb 3, 2025

This issue has been waiting for a reporter response for 3 days. It will be auto-closed if no activity occurs in the next 5 days.

@github-actions github-actions bot added the Stale label Feb 3, 2025
Copy link

github-actions bot commented Feb 8, 2025

This issue has not received a reporter response and has been auto-closed. If the issue is still relevant please leave a comment and we can reopen it.

@github-actions github-actions bot closed this as completed Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale waiting-on-reporter Issue is waiting on a reply from the reporter. It will be automatically cloesd if there is no reply.
Development

No branches or pull requests

2 participants