diff options
author | Fake <fatenine@163.com> | 2021-03-31 13:14:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-30 22:14:00 -0700 |
commit | dd2f76498a94f3ef736a2c5a96974c0f1cbca63c (patch) | |
tree | f00fcd6a29fb759e5d82d02b3fdfa360a60ecf9a | |
parent | 23856b8cce06d0ed0a4e65f46bde27df409fe9f6 (diff) | |
download | rabbitmq-c-dd2f76498a94f3ef736a2c5a96974c0f1cbca63c.tar.gz |
ssl: Support password protected keys
-rw-r--r-- | librabbitmq/amqp_openssl.c | 9 | ||||
-rw-r--r-- | librabbitmq/amqp_ssl_socket.h | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/librabbitmq/amqp_openssl.c b/librabbitmq/amqp_openssl.c index 3cebd58..1aa5f1e 100644 --- a/librabbitmq/amqp_openssl.c +++ b/librabbitmq/amqp_openssl.c @@ -498,6 +498,15 @@ int amqp_ssl_socket_set_cert(amqp_socket_t *base, const char *cert) { return AMQP_STATUS_OK; } +void amqp_ssl_socket_set_key_passwd(amqp_socket_t *base, const char *passwd) { + struct amqp_ssl_socket_t *self; + if (base->klass != &amqp_ssl_socket_class) { + amqp_abort("<%p> is not of type amqp_ssl_socket_t", base); + } + self = (struct amqp_ssl_socket_t *)base; + SSL_CTX_set_default_passwd_cb_userdata(self->ctx, (void *)passwd); +} + void amqp_ssl_socket_set_verify(amqp_socket_t *base, amqp_boolean_t verify) { amqp_ssl_socket_set_verify_peer(base, verify); amqp_ssl_socket_set_verify_hostname(base, verify); diff --git a/librabbitmq/amqp_ssl_socket.h b/librabbitmq/amqp_ssl_socket.h index 5aab8bf..0a6d58f 100644 --- a/librabbitmq/amqp_ssl_socket.h +++ b/librabbitmq/amqp_ssl_socket.h @@ -86,6 +86,18 @@ int AMQP_CALL amqp_ssl_socket_set_cacert(amqp_socket_t *self, const char *cacert); /** + * Set the password of key in PEM format. + * + * \param [in,out] self An SSL/TLS socket object. + * \param [in] passwd The password of key in PEM format. + * + * \since v0.11.0 + */ +AMQP_PUBLIC_FUNCTION +void AMQP_CALL amqp_ssl_socket_set_key_passwd(amqp_socket_t *self, + const char *passwd); + +/** * Set the client key. * * \param [in,out] self An SSL/TLS socket object. |