Commit 2ac34c25 authored by Ian Craggs's avatar Ian Craggs Committed by GitHub

Merge pull request #260 from fpagliughi/check-non-ssl2

Proposal for non-SSL version error. Issue #251
parents e30861eb 622e740c
...@@ -2298,6 +2298,12 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options) ...@@ -2298,6 +2298,12 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
m->c->sslopts->enabledCipherSuites = MQTTStrdup(options->ssl->enabledCipherSuites); m->c->sslopts->enabledCipherSuites = MQTTStrdup(options->ssl->enabledCipherSuites);
m->c->sslopts->enableServerCertAuth = options->ssl->enableServerCertAuth; m->c->sslopts->enableServerCertAuth = options->ssl->enableServerCertAuth;
} }
#else
if (options->struct_version != 0 && options->ssl)
{
rc = MQTTASYNC_SSL_NOT_SUPPORTED;
goto exit;
}
#endif #endif
m->c->username = options->username; m->c->username = options->username;
......
...@@ -162,6 +162,10 @@ ...@@ -162,6 +162,10 @@
* Return code: no more messages can be buffered * Return code: no more messages can be buffered
*/ */
#define MQTTASYNC_MAX_BUFFERED_MESSAGES -12 #define MQTTASYNC_MAX_BUFFERED_MESSAGES -12
/**
* Return code: Attempting SSL connection using non-SSL version of library
*/
#define MQTTASYNC_SSL_NOT_SUPPORTED -13
/** /**
* Default MQTT version to connect with. Use 3.1.1 then fall back to 3.1 * Default MQTT version to connect with. Use 3.1.1 then fall back to 3.1
......
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
#if defined(OPENSSL) #if defined(OPENSSL)
#include <openssl/ssl.h> #include <openssl/ssl.h>
#else
#define URI_SSL "ssl://"
#endif #endif
#define URI_TCP "tcp://" #define URI_TCP "tcp://"
...@@ -323,13 +325,16 @@ int MQTTClient_create(MQTTClient* handle, const char* serverURI, const char* cli ...@@ -323,13 +325,16 @@ int MQTTClient_create(MQTTClient* handle, const char* serverURI, const char* cli
memset(m, '\0', sizeof(MQTTClients)); memset(m, '\0', sizeof(MQTTClients));
if (strncmp(URI_TCP, serverURI, strlen(URI_TCP)) == 0) if (strncmp(URI_TCP, serverURI, strlen(URI_TCP)) == 0)
serverURI += strlen(URI_TCP); serverURI += strlen(URI_TCP);
#if defined(OPENSSL)
else if (strncmp(URI_SSL, serverURI, strlen(URI_SSL)) == 0) else if (strncmp(URI_SSL, serverURI, strlen(URI_SSL)) == 0)
{ {
#if defined(OPENSSL)
serverURI += strlen(URI_SSL); serverURI += strlen(URI_SSL);
m->ssl = 1; m->ssl = 1;
} #else
rc = MQTTCLIENT_SSL_NOT_SUPPORTED;
goto exit;
#endif #endif
}
m->serverURI = MQTTStrdup(serverURI); m->serverURI = MQTTStrdup(serverURI);
ListAppend(handles, m, sizeof(MQTTClients)); ListAppend(handles, m, sizeof(MQTTClients));
......
...@@ -167,6 +167,10 @@ ...@@ -167,6 +167,10 @@
* Return code: A QoS value that falls outside of the acceptable range (0,1,2) * Return code: A QoS value that falls outside of the acceptable range (0,1,2)
*/ */
#define MQTTCLIENT_BAD_QOS -9 #define MQTTCLIENT_BAD_QOS -9
/**
* Return code: Attempting SSL connection using non-SSL version of library
*/
#define MQTTCLIENT_SSL_NOT_SUPPORTED -10
/** /**
* Default MQTT version to connect with. Use 3.1.1 then fall back to 3.1 * Default MQTT version to connect with. Use 3.1.1 then fall back to 3.1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment