Function amqp_set_ssl_engine

Synopsis

#include <librabbitmq/amqp_ssl_socket.h>

int amqp_set_ssl_engine(const char *engine)

Description

Set the engine for underlying SSL/TLS library.

This function is thread-safe, and may be called more than once.

This function requires amqp_initialize_ssl_library() or amqp_ssl_socket_new() has been called.

Parameters:

[ in ] engine - the engine ID

Return
AMQP_STATUS_OK on success.
Since
v0.9.1

Mentioned in

Source

Lines 665-700 in librabbitmq/amqp_openssl.c. Line 272 in librabbitmq/amqp_ssl_socket.h.

int amqp_set_ssl_engine(const char *engine) {
  int status = AMQP_STATUS_OK;
  CHECK_SUCCESS(pthread_mutex_lock(&openssl_init_mutex));

  if (!openssl_initialized) {
    status = AMQP_STATUS_SSL_ERROR;
    goto out;
  }

  if (openssl_engine != NULL) {
    ENGINE_free(openssl_engine);
    openssl_engine = NULL;
  }

  if (engine == NULL) {
    goto out;
  }

  ENGINE_load_builtin_engines();
  openssl_engine = ENGINE_by_id(engine);
  if (openssl_engine == NULL) {
    status = AMQP_STATUS_SSL_SET_ENGINE_FAILED;
    goto out;
  }

  if (ENGINE_set_default(openssl_engine, ENGINE_METHOD_ALL) == 0) {
    ENGINE_free(openssl_engine);
    openssl_engine = NULL;
    status = AMQP_STATUS_SSL_SET_ENGINE_FAILED;
    goto out;
  }

out:
  CHECK_SUCCESS(pthread_mutex_unlock(&openssl_init_mutex));
  return status;
}





Add Discussion as Guest

Log in to DocsForge