diff options
author | Alan Antonuk <alan.antonuk@gmail.com> | 2017-02-20 12:03:34 -0800 |
---|---|---|
committer | Alan Antonuk <alan.antonuk@gmail.com> | 2017-02-20 12:48:40 -0800 |
commit | ab256d1f23785845aa4514db6ca75982b590e345 (patch) | |
tree | 99119e48a41feceee108d93003c339afff2a7c48 /librabbitmq/amqp_openssl.c | |
parent | 77a583f33e8e10682edf3fc14833c7bf19a3fc98 (diff) | |
download | rabbitmq-c-ssl_bio.tar.gz |
ssl: Add OpenSSL BIO that passes MSG_NOSIGNALssl_bio
Add an OpenSSL BIO that ignores SIGPIPE by passing MSG_NOSIGNAL to the
send() and recv() calls on platforms that support it.
Fixes #401
Diffstat (limited to 'librabbitmq/amqp_openssl.c')
-rw-r--r-- | librabbitmq/amqp_openssl.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/librabbitmq/amqp_openssl.c b/librabbitmq/amqp_openssl.c index 68808bb..333c7ed 100644 --- a/librabbitmq/amqp_openssl.c +++ b/librabbitmq/amqp_openssl.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include "amqp_openssl_bio.h" #include "amqp_openssl_hostname_validation.h" #include "amqp_ssl_socket.h" #include "amqp_socket.h" @@ -38,6 +39,7 @@ #include <ctype.h> #include <limits.h> +#include <openssl/bio.h> #include <openssl/conf.h> #include <openssl/err.h> #include <openssl/ssl.h> @@ -172,6 +174,7 @@ amqp_ssl_socket_open(void *base, const char *host, int port, struct timeval *tim int status; amqp_time_t deadline; X509 *cert; + BIO *bio; if (-1 != self->sockfd) { return AMQP_STATUS_SOCKET_INUSE; } @@ -197,13 +200,15 @@ amqp_ssl_socket_open(void *base, const char *host, int port, struct timeval *tim goto error_out1; } - status = SSL_set_fd(self->ssl, self->sockfd); - if (!status) { - self->internal_error = SSL_get_error(self->ssl, status); - status = AMQP_STATUS_SSL_ERROR; + bio = BIO_new(amqp_openssl_bio()); + if (!bio) { + status = AMQP_STATUS_NO_MEMORY; goto error_out2; } + BIO_set_fd(bio, self->sockfd, BIO_NOCLOSE); + SSL_set_bio(self->ssl, bio, bio); + start_connect: status = SSL_connect(self->ssl); if (status != 1) { |