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

Confusing variable naming in certbot/acme (private_key/privkey) #9941

Closed
RS-Credentive opened this issue May 15, 2024 · 1 comment
Closed

Comments

@RS-Credentive
Copy link

While following along with the code in the crypto_util modules in acme and certbot, I was very confused by the references to the private key as the "Key to include in the CSR", since the public key is the one included in the CSR.

The reference to the private key continues until this call in acme.crypt_util

csr.set_pubkey(private_key)

Since it appears that the public key is the one being used, is it appropriate to refer to it as a public_key/pubkey rather than a private_key/privkey?

Will you accept a PR to change the variable name for purposes of clarity?

@osirisinferi
Copy link
Collaborator

The set_pubkey() method of the crypto.X509Req class accepts the OpenSSL.crypto.PKey class as argument. And that PKey can be a public key or key pair. When a key pair (private key) is used, it will extract the public key from the private key.

Notice how the private_key variable is really a private key, as it's being loaded from crypto.load_privatekey() and is also used by the csr.sign() method, which obviously requires a private key.

Thus the variable name is actually quite correct and personally I don't find it really confusing in the preamble of generate_csr() to be honest, as everybody knows it's the public part of the key pair/private key that gets embedded in the CSR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants