Skip to content

Setter for certificate and certificate_chain ? #576

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

Open
martenrichter opened this issue Apr 5, 2025 · 2 comments
Open

Setter for certificate and certificate_chain ? #576

martenrichter opened this issue Apr 5, 2025 · 2 comments

Comments

@martenrichter
Copy link

Would it be possible to have a stable setter function for certificate and certificate_chain to load a certificate in memory without an external file? (see

certificate: Any = None
)
So far, I used accessed the internal variable directly, but this may not be a good idea for a wpt test:
web-platform-tests/wpt#50263

@jlaine
Copy link
Contributor

jlaine commented Apr 6, 2025

Hi!

I assume you would also need a setter for the private key?

While, I'm not opposed to it, it does mean committing to using cryptography's certificate / private key classes as part of our public API:

  • For certificates, the type annotation is quite straight-forward: cryptography.x509.Certificate
  • For private keys it's less obvious, it would probably have to be a Union of all the private key types we support

@martenrichter
Copy link
Author

Yes, it would also be for the private Key. Currently, I do:

configuration.private_key =  serialization.load_pem_private_key(self.cert_hash_info["private_key"],
                                                                            password=None
                                                                            )
configuration.certificate = x509.load_pem_x509_certificate(self.cert_hash_info["certificate"])
configuration.certificate_chain = []

However, it can also be another format, such as a string with a PEM inside, or some else stable.

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

No branches or pull requests

2 participants