Check for TLS use in serverURIs if there are no TLS options #1566

This commit is contained in:
Ian Craggs 2025-08-15 17:41:14 +01:00
parent 7a7519c9f6
commit 71fb9571bc
No known key found for this signature in database
GPG Key ID: A7AE1A8F2CCAB186
1 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2024 IBM Corp., Ian Craggs and others
* Copyright (c) 2009, 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
@ -589,6 +589,23 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
rc = MQTTASYNC_NULL_PARAMETER;
goto exit;
}
if (options->ssl == NULL && options->serverURIcount > 0)
{
int i = 0;
for (i = 0; i < options->serverURIcount; i++)
{
char* serverURI = options->serverURIs[i];
printf("checking %s\n", serverURI);
if (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)
{
rc = MQTTASYNC_NULL_PARAMETER;
goto exit;
}
}
}
#endif
if (options->will) /* check validity of will options structure */