Commit 4e619837 authored by Ian Craggs's avatar Ian Craggs

Undo size_t API changes (binary incompatibility) and add const qualifiers to SSL…

Undo size_t API changes (binary incompatibility) and add const qualifiers to SSL options in MQTTClient.h
parent 03d9cdf2
...@@ -1982,16 +1982,16 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options) ...@@ -1982,16 +1982,16 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
if (m->c->sslopts) if (m->c->sslopts)
{ {
if (m->c->sslopts->trustStore) if (m->c->sslopts->trustStore)
free(m->c->sslopts->trustStore); free((void*)m->c->sslopts->trustStore);
if (m->c->sslopts->keyStore) if (m->c->sslopts->keyStore)
free(m->c->sslopts->keyStore); free((void*)m->c->sslopts->keyStore);
if (m->c->sslopts->privateKey) if (m->c->sslopts->privateKey)
free(m->c->sslopts->privateKey); free((void*)m->c->sslopts->privateKey);
if (m->c->sslopts->privateKeyPassword) if (m->c->sslopts->privateKeyPassword)
free(m->c->sslopts->privateKeyPassword); free((void*)m->c->sslopts->privateKeyPassword);
if (m->c->sslopts->enabledCipherSuites) if (m->c->sslopts->enabledCipherSuites)
free(m->c->sslopts->enabledCipherSuites); free((void*)m->c->sslopts->enabledCipherSuites);
free(m->c->sslopts); free((void*)m->c->sslopts);
m->c->sslopts = NULL; m->c->sslopts = NULL;
} }
...@@ -2000,30 +2000,15 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options) ...@@ -2000,30 +2000,15 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
m->c->sslopts = malloc(sizeof(MQTTClient_SSLOptions)); m->c->sslopts = malloc(sizeof(MQTTClient_SSLOptions));
memset(m->c->sslopts, '\0', sizeof(MQTTClient_SSLOptions)); memset(m->c->sslopts, '\0', sizeof(MQTTClient_SSLOptions));
if (options->ssl->trustStore) if (options->ssl->trustStore)
{ m->c->sslopts->trustStore = MQTTStrdup(options->ssl->trustStore);
m->c->sslopts->trustStore = malloc(strlen(options->ssl->trustStore) + 1);
strcpy(m->c->sslopts->trustStore, options->ssl->trustStore);
}
if (options->ssl->keyStore) if (options->ssl->keyStore)
{ m->c->sslopts->keyStore = MQTTStrdup(options->ssl->keyStore);
m->c->sslopts->keyStore = malloc(strlen(options->ssl->keyStore) + 1);
strcpy(m->c->sslopts->keyStore, options->ssl->keyStore);
}
if (options->ssl->privateKey) if (options->ssl->privateKey)
{ m->c->sslopts->privateKey = MQTTStrdup(options->ssl->privateKey);
m->c->sslopts->privateKey = malloc(strlen(options->ssl->privateKey) + 1);
strcpy(m->c->sslopts->privateKey, options->ssl->privateKey);
}
if (options->ssl->privateKeyPassword) if (options->ssl->privateKeyPassword)
{ m->c->sslopts->privateKeyPassword = MQTTStrdup(options->ssl->privateKeyPassword);
m->c->sslopts->privateKeyPassword = malloc(strlen(options->ssl->privateKeyPassword) + 1);
strcpy(m->c->sslopts->privateKeyPassword, options->ssl->privateKeyPassword);
}
if (options->ssl->enabledCipherSuites) if (options->ssl->enabledCipherSuites)
{ m->c->sslopts->enabledCipherSuites = MQTTStrdup(options->ssl->enabledCipherSuites);
m->c->sslopts->enabledCipherSuites = malloc(strlen(options->ssl->enabledCipherSuites) + 1);
strcpy(m->c->sslopts->enabledCipherSuites, options->ssl->enabledCipherSuites);
}
m->c->sslopts->enableServerCertAuth = options->ssl->enableServerCertAuth; m->c->sslopts->enableServerCertAuth = options->ssl->enableServerCertAuth;
} }
#endif #endif
...@@ -2138,10 +2123,10 @@ int MQTTAsync_isConnected(MQTTAsync handle) ...@@ -2138,10 +2123,10 @@ int MQTTAsync_isConnected(MQTTAsync handle)
} }
int MQTTAsync_subscribeMany(MQTTAsync handle, size_t count, char* const* topic, int* qos, MQTTAsync_responseOptions* response) int MQTTAsync_subscribeMany(MQTTAsync handle, int count, char* const* topic, int* qos, MQTTAsync_responseOptions* response)
{ {
MQTTAsyncs* m = handle; MQTTAsyncs* m = handle;
size_t i = 0; int i = 0;
int rc = MQTTASYNC_FAILURE; int rc = MQTTASYNC_FAILURE;
MQTTAsync_queuedCommand* sub; MQTTAsync_queuedCommand* sub;
int msgid = 0; int msgid = 0;
...@@ -2216,10 +2201,10 @@ int MQTTAsync_subscribe(MQTTAsync handle, const char* topic, int qos, MQTTAsync_ ...@@ -2216,10 +2201,10 @@ int MQTTAsync_subscribe(MQTTAsync handle, const char* topic, int qos, MQTTAsync_
} }
int MQTTAsync_unsubscribeMany(MQTTAsync handle, size_t count, char* const* topic, MQTTAsync_responseOptions* response) int MQTTAsync_unsubscribeMany(MQTTAsync handle, int count, char* const* topic, MQTTAsync_responseOptions* response)
{ {
MQTTAsyncs* m = handle; MQTTAsyncs* m = handle;
size_t i = 0; int i = 0;
int rc = SOCKET_ERROR; int rc = SOCKET_ERROR;
MQTTAsync_queuedCommand* unsub; MQTTAsync_queuedCommand* unsub;
int msgid = 0; int msgid = 0;
...@@ -2285,7 +2270,7 @@ int MQTTAsync_unsubscribe(MQTTAsync handle, const char* topic, MQTTAsync_respons ...@@ -2285,7 +2270,7 @@ int MQTTAsync_unsubscribe(MQTTAsync handle, const char* topic, MQTTAsync_respons
} }
int MQTTAsync_send(MQTTAsync handle, const char* destinationName, size_t payloadlen, void* payload, int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen, void* payload,
int qos, int retained, MQTTAsync_responseOptions* response) int qos, int retained, MQTTAsync_responseOptions* response)
{ {
int rc = MQTTASYNC_SUCCESS; int rc = MQTTASYNC_SUCCESS;
......
...@@ -817,7 +817,7 @@ DLLExport int MQTTAsync_subscribe(MQTTAsync handle, const char* topic, int qos, ...@@ -817,7 +817,7 @@ DLLExport int MQTTAsync_subscribe(MQTTAsync handle, const char* topic, int qos,
* An error code is returned if there was a problem registering the * An error code is returned if there was a problem registering the
* subscriptions. * subscriptions.
*/ */
DLLExport int MQTTAsync_subscribeMany(MQTTAsync handle, size_t count, char* const* topic, int* qos, MQTTAsync_responseOptions* response); DLLExport int MQTTAsync_subscribeMany(MQTTAsync handle, int count, char* const* topic, int* qos, MQTTAsync_responseOptions* response);
/** /**
* This function attempts to remove an existing subscription made by the * This function attempts to remove an existing subscription made by the
...@@ -845,7 +845,7 @@ DLLExport int MQTTAsync_unsubscribe(MQTTAsync handle, const char* topic, MQTTAsy ...@@ -845,7 +845,7 @@ DLLExport int MQTTAsync_unsubscribe(MQTTAsync handle, const char* topic, MQTTAsy
* @return ::MQTTASYNC_SUCCESS if the subscriptions are removed. * @return ::MQTTASYNC_SUCCESS if the subscriptions are removed.
* An error code is returned if there was a problem removing the subscriptions. * An error code is returned if there was a problem removing the subscriptions.
*/ */
DLLExport int MQTTAsync_unsubscribeMany(MQTTAsync handle, size_t count, char* const* topic, MQTTAsync_responseOptions* response); DLLExport int MQTTAsync_unsubscribeMany(MQTTAsync handle, int count, char* const* topic, MQTTAsync_responseOptions* response);
/** /**
...@@ -866,7 +866,7 @@ DLLExport int MQTTAsync_unsubscribeMany(MQTTAsync handle, size_t count, char* co ...@@ -866,7 +866,7 @@ DLLExport int MQTTAsync_unsubscribeMany(MQTTAsync handle, size_t count, char* co
* @return ::MQTTASYNC_SUCCESS if the message is accepted for publication. * @return ::MQTTASYNC_SUCCESS if the message is accepted for publication.
* An error code is returned if there was a problem accepting the message. * An error code is returned if there was a problem accepting the message.
*/ */
DLLExport int MQTTAsync_send(MQTTAsync handle, const char* destinationName, size_t payloadlen, void* payload, int qos, int retained, DLLExport int MQTTAsync_send(MQTTAsync handle, const char* destinationName, int payloadlen, void* payload, int qos, int retained,
MQTTAsync_responseOptions* response); MQTTAsync_responseOptions* response);
......
...@@ -970,15 +970,15 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options, ...@@ -970,15 +970,15 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options,
if (m->c->sslopts) if (m->c->sslopts)
{ {
if (m->c->sslopts->trustStore) if (m->c->sslopts->trustStore)
free(m->c->sslopts->trustStore); free((void*)m->c->sslopts->trustStore);
if (m->c->sslopts->keyStore) if (m->c->sslopts->keyStore)
free(m->c->sslopts->keyStore); free((void*)m->c->sslopts->keyStore);
if (m->c->sslopts->privateKey) if (m->c->sslopts->privateKey)
free(m->c->sslopts->privateKey); free((void*)m->c->sslopts->privateKey);
if (m->c->sslopts->privateKeyPassword) if (m->c->sslopts->privateKeyPassword)
free(m->c->sslopts->privateKeyPassword); free((void*)m->c->sslopts->privateKeyPassword);
if (m->c->sslopts->enabledCipherSuites) if (m->c->sslopts->enabledCipherSuites)
free(m->c->sslopts->enabledCipherSuites); free((void*)m->c->sslopts->enabledCipherSuites);
free(m->c->sslopts); free(m->c->sslopts);
m->c->sslopts = NULL; m->c->sslopts = NULL;
} }
......
...@@ -462,19 +462,19 @@ typedef struct ...@@ -462,19 +462,19 @@ typedef struct
int struct_version; int struct_version;
/** The file in PEM format containing the public digital certificates trusted by the client. */ /** The file in PEM format containing the public digital certificates trusted by the client. */
char* trustStore; const char* trustStore;
/** The file in PEM format containing the public certificate chain of the client. It may also include /** The file in PEM format containing the public certificate chain of the client. It may also include
* the client's private key. * the client's private key.
*/ */
char* keyStore; const char* keyStore;
/** If not included in the sslKeyStore, this setting points to the file in PEM format containing /** If not included in the sslKeyStore, this setting points to the file in PEM format containing
* the client's private key. * the client's private key.
*/ */
char* privateKey; const char* privateKey;
/** The password to load the client's privateKey if encrypted. */ /** The password to load the client's privateKey if encrypted. */
char* privateKeyPassword; const char* privateKeyPassword;
/** /**
* The list of cipher suites that the client will present to the server during the SSL handshake. For a * The list of cipher suites that the client will present to the server during the SSL handshake. For a
...@@ -484,7 +484,7 @@ typedef struct ...@@ -484,7 +484,7 @@ typedef struct
* those offering no encryption- will be considered. * those offering no encryption- will be considered.
* This setting can be used to set an SSL anonymous connection ("aNULL" string value, for instance). * This setting can be used to set an SSL anonymous connection ("aNULL" string value, for instance).
*/ */
char* enabledCipherSuites; const char* enabledCipherSuites;
/** True/False option to enable verification of the server certificate **/ /** True/False option to enable verification of the server certificate **/
int enableServerCertAuth; int enableServerCertAuth;
......
...@@ -666,15 +666,15 @@ void MQTTProtocol_freeClient(Clients* client) ...@@ -666,15 +666,15 @@ void MQTTProtocol_freeClient(Clients* client)
if (client->sslopts) if (client->sslopts)
{ {
if (client->sslopts->trustStore) if (client->sslopts->trustStore)
free(client->sslopts->trustStore); free((void*)client->sslopts->trustStore);
if (client->sslopts->keyStore) if (client->sslopts->keyStore)
free(client->sslopts->keyStore); free((void*)client->sslopts->keyStore);
if (client->sslopts->privateKey) if (client->sslopts->privateKey)
free(client->sslopts->privateKey); free((void*)client->sslopts->privateKey);
if (client->sslopts->privateKeyPassword) if (client->sslopts->privateKeyPassword)
free(client->sslopts->privateKeyPassword); free((void*)client->sslopts->privateKeyPassword);
if (client->sslopts->enabledCipherSuites) if (client->sslopts->enabledCipherSuites)
free(client->sslopts->enabledCipherSuites); free((void*)client->sslopts->enabledCipherSuites);
free(client->sslopts); free(client->sslopts);
} }
#endif #endif
......
...@@ -449,7 +449,7 @@ void SSLSocket_terminate() ...@@ -449,7 +449,7 @@ void SSLSocket_terminate()
int SSLSocket_createContext(networkHandles* net, MQTTClient_SSLOptions* opts) int SSLSocket_createContext(networkHandles* net, MQTTClient_SSLOptions* opts)
{ {
int rc = 1; int rc = 1;
char* ciphers = NULL; const char* ciphers = NULL;
FUNC_ENTRY; FUNC_ENTRY;
if (net->ctx == NULL) if (net->ctx == NULL)
......
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