Merge branch 'pluraf-develop' into develop

This commit is contained in:
Ian Craggs 2025-08-15 15:56:03 +01:00
commit 248b64598b
No known key found for this signature in database
GPG Key ID: A7AE1A8F2CCAB186
10 changed files with 54 additions and 12 deletions

View File

@ -335,6 +335,7 @@ int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const
&& strncmp(URI_WS, serverURI, strlen(URI_WS)) != 0
#if defined(OPENSSL)
&& strncmp(URI_SSL, serverURI, strlen(URI_SSL)) != 0
&& strncmp(URI_TLS, serverURI, strlen(URI_TLS)) != 0
&& strncmp(URI_MQTTS, serverURI, strlen(URI_MQTTS)) != 0
&& strncmp(URI_WSS, serverURI, strlen(URI_WSS)) != 0
#endif
@ -405,6 +406,11 @@ int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const
serverURI += strlen(URI_SSL);
m->ssl = 1;
}
else if (strncmp(URI_TLS, serverURI, strlen(URI_TLS)) == 0)
{
serverURI += strlen(URI_TLS);
m->ssl = 1;
}
else if (strncmp(URI_MQTTS, serverURI, strlen(URI_MQTTS)) == 0)
{
serverURI += strlen(URI_MQTTS);

View File

@ -177,11 +177,11 @@
/**
* Return code: protocol prefix in serverURI should be:
* @li @em tcp:// or @em mqtt:// - Insecure TCP
* @li @em ssl:// or @em mqtts:// - Encrypted SSL/TLS
* @li @em ssl:// or @em tls:// or @em mqtts:// - Encrypted SSL/TLS
* @li @em ws:// - Insecure websockets
* @li @em wss:// - Secure web sockets
*
* The TLS enabled prefixes (ssl, mqtts, wss) are only valid if the TLS
* The TLS enabled prefixes (ssl, tls, mqtts, wss) are only valid if the TLS
* version of the library is linked with.
*/
#define MQTTASYNC_BAD_PROTOCOL -14

View File

@ -1348,6 +1348,11 @@ static int MQTTAsync_processCommand(void)
serverURI += strlen(URI_SSL);
command->client->ssl = 1;
}
else if (strncmp(URI_TLS, serverURI, strlen(URI_TLS)) == 0)
{
serverURI += strlen(URI_TLS);
command->client->ssl = 1;
}
else if (strncmp(URI_MQTTS, serverURI, strlen(URI_MQTTS)) == 0)
{
serverURI += strlen(URI_MQTTS);
@ -2896,6 +2901,11 @@ static int MQTTAsync_connecting(MQTTAsyncs* m)
serverURI += strlen(URI_SSL);
default_port = SECURE_MQTT_DEFAULT_PORT;
}
else if (strncmp(URI_TLS, serverURI, strlen(URI_TLS)) == 0)
{
serverURI += strlen(URI_TLS);
default_port = SECURE_MQTT_DEFAULT_PORT;
}
else if (strncmp(URI_MQTTS, serverURI, strlen(URI_MQTTS)) == 0)
{
serverURI += strlen(URI_MQTTS);

View File

@ -71,6 +71,7 @@
#include <openssl/ssl.h>
#else
#define URI_SSL "ssl://"
#define URI_TLS "tls://"
#define URI_MQTTS "mqtts://"
#endif
@ -403,6 +404,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
&& strncmp(URI_WS, serverURI, strlen(URI_WS)) != 0
#if defined(OPENSSL)
&& strncmp(URI_SSL, serverURI, strlen(URI_SSL)) != 0
&& strncmp(URI_TLS, serverURI, strlen(URI_TLS)) != 0
&& strncmp(URI_MQTTS, serverURI, strlen(URI_MQTTS)) != 0
&& strncmp(URI_WSS, serverURI, strlen(URI_WSS)) != 0
#endif
@ -465,6 +467,16 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
#else
rc = MQTTCLIENT_SSL_NOT_SUPPORTED;
goto exit;
#endif
}
else if (strncmp(URI_TLS, serverURI, strlen(URI_TLS)) == 0)
{
#if defined(OPENSSL)
serverURI += strlen(URI_TLS);
m->ssl = 1;
#else
rc = MQTTCLIENT_SSL_NOT_SUPPORTED;
goto exit;
#endif
}
else if (strncmp(URI_MQTTS, serverURI, strlen(URI_MQTTS)) == 0)
@ -1898,6 +1910,11 @@ MQTTResponse MQTTClient_connectAll(MQTTClient handle, MQTTClient_connectOptions*
serverURI += strlen(URI_SSL);
m->ssl = 1;
}
else if (strncmp(URI_TLS, serverURI, strlen(URI_TLS)) == 0)
{
serverURI += strlen(URI_TLS);
m->ssl = 1;
}
else if (strncmp(URI_MQTTS, serverURI, strlen(URI_MQTTS)) == 0)
{
serverURI += strlen(URI_MQTTS);

View File

@ -186,10 +186,10 @@
/**
* Return code: protocol prefix in serverURI should be:
* @li @em tcp:// or @em mqtt:// - Insecure TCP
* @li @em ssl:// or @em mqtts:// - Encrypted SSL/TLS
* @li @em ssl:// or @em tls:// or @em mqtts:// - Encrypted SSL/TLS
* @li @em ws:// - Insecure websockets
* @li @em wss:// - Secure web sockets
* The TLS enabled prefixes (ssl, mqtts, wss) are only valid if a TLS
* The TLS enabled prefixes (ssl, tls, mqtts, wss) are only valid if a TLS
* version of the library is linked with.
*/
#define MQTTCLIENT_BAD_PROTOCOL -14

View File

@ -3,15 +3,15 @@
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* The Eclipse Public License is available at
* https://www.eclipse.org/legal/epl-2.0/
* and the Eclipse Distribution License is available at
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs, Allan Stockdill-Mander - initial implementation
* Ian Craggs, Allan Stockdill-Mander - initial implementation
* Ian Craggs - SNI support
* Ian Craggs - post connect checks and CApath
*******************************************************************************/
@ -31,6 +31,7 @@
#include "Clients.h"
#define URI_SSL "ssl://"
#define URI_TLS "tls://"
#define URI_MQTTS "mqtts://"
/** if we should handle openssl initialization (bool_value == 1) or depend on it to be initalized externally (bool_value == 0) */

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2020 IBM Corp., and others
* Copyright (c) 2012, 2025 IBM Corp., Ian Craggs and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
@ -314,6 +314,8 @@ void myconnect(MQTTAsync client)
}
if (opts.connection && (strncmp(opts.connection, "ssl://", 6) == 0 ||
strncmp(opts.connection, "tls://", 6) == 0 ||
strncmp(opts.connection, "mqtts://", 7) == 0 ||
strncmp(opts.connection, "wss://", 6) == 0))
{
if (opts.insecure)

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2020 IBM Corp., and others
* Copyright (c) 2012, 2025 IBM Corp., Ian Craggs and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
@ -303,6 +303,8 @@ int main(int argc, char** argv)
}
if (opts.connection && (strncmp(opts.connection, "ssl://", 6) == 0 ||
strncmp(opts.connection, "tls://", 6) == 0||
strncmp(opts.connection, "mqtts://", 7) == 0 ||
strncmp(opts.connection, "wss://", 6) == 0))
{
ssl_opts.verify = (opts.insecure) ? 0 : 1;

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2022 IBM Corp.
* Copyright (c) 2012, 2025 IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
@ -85,6 +85,8 @@ int myconnect(MQTTClient client)
}
if (opts.connection && (strncmp(opts.connection, "ssl://", 6) == 0 ||
strncmp(opts.connection, "tls://", 6) == 0 ||
strncmp(opts.connection, "mqtts://", 7) == 0 ||
strncmp(opts.connection, "wss://", 6) == 0))
{
if (opts.insecure)

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2022 IBM Corp., and others
* Copyright (c) 2012, 2025 IBM Corp., Ian Craggs and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
@ -82,6 +82,8 @@ int myconnect(MQTTClient client)
}
if (opts.connection && (strncmp(opts.connection, "ssl://", 6) == 0 ||
strncmp(opts.connection, "tls://", 6) == 0 ||
strncmp(opts.connection, "mqtts://", 7) == 0 ||
strncmp(opts.connection, "wss://", 6) == 0))
{
if (opts.insecure)