Commit 622e740c authored by fmp's avatar fmp

Non-SSL version of the library report an error if the caller requests an SSL…

Non-SSL version of the library report an error if the caller requests an SSL connection. Possible soluiton for Issue #251
parent eabca5bf
......@@ -2318,6 +2318,12 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
m->c->sslopts->enabledCipherSuites = MQTTStrdup(options->ssl->enabledCipherSuites);
m->c->sslopts->enableServerCertAuth = options->ssl->enableServerCertAuth;
}
#else
if (options->struct_version != 0 && options->ssl)
{
rc = MQTTASYNC_SSL_NOT_SUPPORTED;
goto exit;
}
#endif
m->c->username = options->username;
......
......@@ -161,6 +161,10 @@
* Return code: no more messages can be buffered
*/
#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
......
......@@ -61,6 +61,8 @@
#if defined(OPENSSL)
#include <openssl/ssl.h>
#else
#define URI_SSL "ssl://"
#endif
#define URI_TCP "tcp://"
......@@ -323,13 +325,16 @@ int MQTTClient_create(MQTTClient* handle, const char* serverURI, const char* cli
memset(m, '\0', sizeof(MQTTClients));
if (strncmp(URI_TCP, serverURI, strlen(URI_TCP)) == 0)
serverURI += strlen(URI_TCP);
#if defined(OPENSSL)
else if (strncmp(URI_SSL, serverURI, strlen(URI_SSL)) == 0)
{
#if defined(OPENSSL)
serverURI += strlen(URI_SSL);
m->ssl = 1;
}
#else
rc = MQTTCLIENT_SSL_NOT_SUPPORTED;
goto exit;
#endif
}
m->serverURI = MQTTStrdup(serverURI);
ListAppend(handles, m, sizeof(MQTTClients));
......
......@@ -166,6 +166,10 @@
* Return code: A QoS value that falls outside of the acceptable range (0,1,2)
*/
#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
......
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