Function amqp_ssl_socket_set_key

Synopsis

#include <librabbitmq/amqp_ssl_socket.h>

int amqp_ssl_socket_set_key(amqp_socket_t *self, const char *cert, const char *key)

Description

Set the client key.

Parameters:

[ in,out ] self - An SSL/TLS socket object.

[ in ] cert - Path to the client certificate in PEM foramt.

[ in ] key - Path to the client key in PEM format.

Return
AMQP_STATUS_OK on success an amqp_status_enum value on failure.
Since
v0.4.0

Mentioned in

Source

Lines 397-414 in librabbitmq/amqp_openssl.c. Line 101 in librabbitmq/amqp_ssl_socket.h.

int amqp_ssl_socket_set_key(amqp_socket_t *base, const char *cert,
                            const char *key) {
  int status;
  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;
  status = SSL_CTX_use_certificate_chain_file(self->ctx, cert);
  if (1 != status) {
    return AMQP_STATUS_SSL_ERROR;
  }
  status = SSL_CTX_use_PrivateKey_file(self->ctx, key, SSL_FILETYPE_PEM);
  if (1 != status) {
    return AMQP_STATUS_SSL_ERROR;
  }
  return AMQP_STATUS_OK;
}





Add Discussion as Guest

Log in to DocsForge