Skip to content

Add support for wolfSSL Context password callback#14

Merged
cconlon merged 1 commit intowolfSSL:masterfrom
tmael:pem-passwd-cb
Aug 7, 2020
Merged

Add support for wolfSSL Context password callback#14
cconlon merged 1 commit intowolfSSL:masterfrom
tmael:pem-passwd-cb

Conversation

@tmael
Copy link
Copy Markdown
Contributor

@tmael tmael commented Aug 5, 2020

This PR adds support to register a default password callback.

The load_cert_chain() python API can now accept the password parameter encoded using UTF-8.

You can use the set_passwd_cb() python API to register a callback function that sets the password before loading an encrypted key using a call to load_cert_chain().

The builder script has been updated to include wolfSSL_CTX_set_default_passwd_cb() wolfSSL API.

This password callback feature allows urllib3 tests in wolfSSL/osp#36 to work:

TestHTTPS::test_client_key_password
TestHTTPS_TLSv1::test_client_key_password
TestClientCerts::test_client_cert_with_string_password
TestClientCerts::test_client_cert_with_bytes_password
TestClientCerts::test_load_keyfile_with_invalid_password

Here's an example of how to use it:

    def load_cert_chain(self, certfile, keyfile=None, password=None):
        if password is not None:
            if not isinstance(password, six.binary_type):
                password = password.encode("utf-8")
            self._ctx.set_passwd_cb(lambda *_: password)
        self._ctx.load_cert_chain(certfile, keyfile=keyfile, password=password)

@tmael tmael requested a review from cconlon August 5, 2020 18:30
@cconlon cconlon merged commit 9bef875 into wolfSSL:master Aug 7, 2020
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

Successfully merging this pull request may close these issues.

2 participants