summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Antonuk <aega@med.umich.edu>2012-05-29 15:49:46 -0400
committerAlan Antonuk <aega@med.umich.edu>2012-05-29 15:49:46 -0400
commitfab72882d7b033da8612c499c6c30457271dd5e4 (patch)
treecd2da5b7fddc5140ac6440f6824a1bdcbdc2f2cf
parent4aec7e615f6111b6c55aac20877446dfb2fb82ce (diff)
downloadrabbitmq-c-github-ask-fab72882d7b033da8612c499c6c30457271dd5e4.tar.gz
Adding amqp_set_initialize_ssl_library() API function
Function sets whether or not rabbitmq-c will initialize the underlying SSL library
-rw-r--r--librabbitmq/amqp-cyassl.c5
-rw-r--r--librabbitmq/amqp-gnutls.c5
-rw-r--r--librabbitmq/amqp-openssl.c12
-rw-r--r--librabbitmq/amqp-polarssl.c5
-rw-r--r--librabbitmq/amqp-ssl.h26
5 files changed, 53 insertions, 0 deletions
diff --git a/librabbitmq/amqp-cyassl.c b/librabbitmq/amqp-cyassl.c
index 960e209..80d5774 100644
--- a/librabbitmq/amqp-cyassl.c
+++ b/librabbitmq/amqp-cyassl.c
@@ -172,3 +172,8 @@ error:
amqp_ssl_socket_close(sockfd, self);
return -1;
}
+
+void
+amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize)
+{
+}
diff --git a/librabbitmq/amqp-gnutls.c b/librabbitmq/amqp-gnutls.c
index 3268007..25857db 100644
--- a/librabbitmq/amqp-gnutls.c
+++ b/librabbitmq/amqp-gnutls.c
@@ -249,3 +249,8 @@ error:
sockfd = -1;
goto exit;
}
+
+void
+amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize)
+{
+}
diff --git a/librabbitmq/amqp-openssl.c b/librabbitmq/amqp-openssl.c
index 5e57d69..229e285 100644
--- a/librabbitmq/amqp-openssl.c
+++ b/librabbitmq/amqp-openssl.c
@@ -32,6 +32,9 @@
#include <openssl/ssl.h>
#include <stdlib.h>
+amqp_boolean_t do_initialize_openssl = 1;
+amqp_boolean_t openssl_initialized = 0;
+
struct amqp_ssl_socket_context {
BIO *bio;
SSL_CTX *ctx;
@@ -270,3 +273,12 @@ error:
sockfd = -1;
goto exit;
}
+
+void
+amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize)
+{
+ if (!openssl_initialized)
+ {
+ do_initialize_openssl = do_initialize;
+ }
+}
diff --git a/librabbitmq/amqp-polarssl.c b/librabbitmq/amqp-polarssl.c
index 55dbc43..ae13243 100644
--- a/librabbitmq/amqp-polarssl.c
+++ b/librabbitmq/amqp-polarssl.c
@@ -239,3 +239,8 @@ error:
amqp_ssl_socket_close(self->sockfd, self);
return -1;
}
+
+void
+amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize)
+{
+}
diff --git a/librabbitmq/amqp-ssl.h b/librabbitmq/amqp-ssl.h
index 17cbcc1..0a1ef56 100644
--- a/librabbitmq/amqp-ssl.h
+++ b/librabbitmq/amqp-ssl.h
@@ -59,4 +59,30 @@ amqp_open_ssl_socket(amqp_connection_state_t state,
const char *key,
const char *cert);
+/**
+ * Sets whether rabbitmq-c initializes the underlying SSL library
+ *
+ * For SSL libraries that require a one-time initialization across
+ * a whole program (e.g., OpenSSL) this sets whether or not rabbitmq-c
+ * will initialize the SSL library when the first call to
+ * amqp_open_ssl_socket() is made. You should call this function with
+ * do_init = 0 if the underlying SSL library is intialized somewhere else
+ * the program.
+ *
+ * Failing to initialize or double initialization of the SSL library will
+ * result in undefined behavior
+ *
+ * By default rabbitmq-c will initialize the underlying SSL library
+ *
+ * NOTE: calling this function after the first socket has been opened with
+ * amqp_open_ssl_socket() will not have any effect.
+ *
+ * \param [in] do_initalize, if 0 rabbitmq-c will not initialize the SSL library,
+ * otherwise rabbitmq-c will initialize the SSL library
+ *
+ */
+AMQP_PUBLIC_FUNCTION
+void
+amqp_set_initialize_ssl_library(amqp_boolean_t do_initialize);
+
#endif /* AMQP_SSL_H */