Skip to content

Commit dd2f764

Browse files
authored
ssl: Support password protected keys
1 parent 23856b8 commit dd2f764

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

librabbitmq/amqp_openssl.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ int amqp_ssl_socket_set_cert(amqp_socket_t *base, const char *cert) {
498498
return AMQP_STATUS_OK;
499499
}
500500

501+
void amqp_ssl_socket_set_key_passwd(amqp_socket_t *base, const char *passwd) {
502+
struct amqp_ssl_socket_t *self;
503+
if (base->klass != &amqp_ssl_socket_class) {
504+
amqp_abort("<%p> is not of type amqp_ssl_socket_t", base);
505+
}
506+
self = (struct amqp_ssl_socket_t *)base;
507+
SSL_CTX_set_default_passwd_cb_userdata(self->ctx, (void *)passwd);
508+
}
509+
501510
void amqp_ssl_socket_set_verify(amqp_socket_t *base, amqp_boolean_t verify) {
502511
amqp_ssl_socket_set_verify_peer(base, verify);
503512
amqp_ssl_socket_set_verify_hostname(base, verify);

librabbitmq/amqp_ssl_socket.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ AMQP_PUBLIC_FUNCTION
8585
int AMQP_CALL amqp_ssl_socket_set_cacert(amqp_socket_t *self,
8686
const char *cacert);
8787

88+
/**
89+
* Set the password of key in PEM format.
90+
*
91+
* \param [in,out] self An SSL/TLS socket object.
92+
* \param [in] passwd The password of key in PEM format.
93+
*
94+
* \since v0.11.0
95+
*/
96+
AMQP_PUBLIC_FUNCTION
97+
void AMQP_CALL amqp_ssl_socket_set_key_passwd(amqp_socket_t *self,
98+
const char *passwd);
99+
88100
/**
89101
* Set the client key.
90102
*

0 commit comments

Comments
 (0)