From 6c7ecd7e974917b70686f83b68bd8f8d9378cfea Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Wed, 2 May 2018 19:10:32 +0100 Subject: [PATCH] Fix compiling without TLS. --- lib/net_mosq.c | 4 ++-- lib/options.c | 6 +++++- src/security_default.c | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/net_mosq.c b/lib/net_mosq.c index f143c6db..660845d7 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -443,9 +443,9 @@ int net__socket_connect_tls(struct mosquitto *mosq) #endif +#ifdef WITH_TLS static int net__init_ssl_ctx(struct mosquitto *mosq) { -#ifdef WITH_TLS int ret; if(mosq->ssl_ctx){ @@ -582,9 +582,9 @@ static int net__init_ssl_ctx(struct mosquitto *mosq) } } -#endif return MOSQ_ERR_SUCCESS; } +#endif int net__socket_connect_step3(struct mosquitto *mosq, const char *host, uint16_t port, const char *bind_address, bool blocking) diff --git a/lib/options.c b/lib/options.c index a4fa9038..7f7b51e1 100644 --- a/lib/options.c +++ b/lib/options.c @@ -268,15 +268,19 @@ int mosquitto_opts_set(struct mosquitto *mosq, enum mosq_opt_t option, void *val } break; case MOSQ_OPT_SSL_CTX: +#ifdef WITH_TLS mosq->ssl_ctx = (SSL_CTX *)value; if(mosq->ssl_ctx){ -#if defined(WITH_TLS) && OPENSSL_VERSION_NUMBER >= 0x10100000L +#if OPENSSL_VERSION_NUMBER >= 0x10100000L SSL_CTX_up_ref(mosq->ssl_ctx); #else CRYPTO_add(&(mosq->ssl_ctx)->references, 1, CRYPTO_LOCK_SSL_CTX); #endif } break; +#else + return MOSQ_ERR_NOT_SUPPORTED; +#endif case MOSQ_OPT_SSL_CTX_WITH_DEFAULTS: #if defined(WITH_TLS) && OPENSSL_VERSION_NUMBER >= 0x10100000L mosq->ssl_ctx_defaults = true; diff --git a/src/security_default.c b/src/security_default.c index 993ba4b8..c2a43b26 100644 --- a/src/security_default.c +++ b/src/security_default.c @@ -31,9 +31,9 @@ static int psk__file_parse(struct mosquitto_db *db, struct mosquitto__unpwd **ps #ifdef WITH_TLS static int pw__digest(const char *password, const unsigned char *salt, unsigned int salt_len, unsigned char *hash, unsigned int *hash_len); static int base64__decode(char *in, unsigned char **decoded, unsigned int *decoded_len); +static int mosquitto__memcmp_const(const void *ptr1, const void *b, size_t len); #endif -static int mosquitto__memcmp_const(const void *ptr1, const void *b, size_t len); int mosquitto_security_init_default(struct mosquitto_db *db, bool reload) @@ -749,6 +749,7 @@ static int psk__file_parse(struct mosquitto_db *db, struct mosquitto__unpwd **ps } +#ifdef WITH_TLS static int mosquitto__memcmp_const(const void *a, const void *b, size_t len) { int i; @@ -763,6 +764,7 @@ static int mosquitto__memcmp_const(const void *a, const void *b, size_t len) } return rc; } +#endif int mosquitto_unpwd_check_default(struct mosquitto_db *db, struct mosquitto *context, const char *username, const char *password)