-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
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
SSLContext.load_cert_chain() should accept a password argument #57012
Comments
The SSLContext.load_cert_chain() method should accept a password argument to use if the private key is encrypted. Currently it always uses OpenSSL's default password callback, which prompts the user interactively for a password. I've attached a patch that adds an extra password argument, which can be either a string, bytes, bytearray, or a function to call to get the password. |
It seems a bit strange to me to accept string types or callable in the same argument. If it just supported strings, people could still write password=somefunction(), right? |
The function is only called if the private key is encrypted and a This also parallels the OpenSSL C API, which only accepts a function to |
Here's a new patch that accepts any callable. The old patch only accepted |
Thanks for the patch. This is a generally useful functionality and the patch looks mostly good.
|
Good catch. Here's an updated patch to fix the missing decref in The length check in _password_callback() applies to both callback |
I have one last concern: what is the character set of an OpenSSL password? I see you are using PyUnicode_AsEncodedString(x, NULL, NULL), which basically returns a utf8-encoded bytestring. Since the OpenSSL doc don't specify anything, we could accept it as a best-effort thing. |
OpenSSL doesn't appear to do any special handling for i18n, and just It's not clear to me that PyUnicode_EncodeFSDefault() is quite the right I'm leaning towards just updating the docs to specify that if a string |
Here's a patch with updates to the documentation to more fully specify the |
New changeset cdc6c1b072a5 by Antoine Pitrou in branch 'default': |
Your latest patch was committed, thank you! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: