Skip to content

Commit

Permalink
add ssl struct_version 6
Browse files Browse the repository at this point in the history
  • Loading branch information
binlin.duan committed Sep 27, 2024
1 parent b5352bc commit 5e5b53c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/MQTTAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,16 @@ int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions* options)
free((void*)m->c->sslopts->privateKeyPassword);
if (m->c->sslopts->enabledCipherSuites)
free((void*)m->c->sslopts->enabledCipherSuites);
if (m->c->sslopts->publicKey)
free((void*)m->c->sslopts->publicKey);
if (m->c->sslopts->struct_version >= 2)
{
if (m->c->sslopts->CApath)
free((void*)m->c->sslopts->CApath);
}
if(m->c->sslopts->struct_version >= 6)
{
if (m->c->sslopts->publicKey)
free((void*)m->c->sslopts->publicKey);
}
free((void*)m->c->sslopts);
m->c->sslopts = NULL;
}
Expand Down
10 changes: 7 additions & 3 deletions src/MQTTAsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -1070,12 +1070,13 @@ typedef struct
/** The eyecatcher for this structure. Must be MQTS */
char struct_id[4];

/** The version number of this structure. Must be 0, 1, 2, 3, 4 or 5.
/** The version number of this structure. Must be 0, 1, 2, 3, 4, 5 or 6.
* 0 means no sslVersion
* 1 means no verify, CApath
* 2 means no ssl_error_context, ssl_error_cb
* 3 means no ssl_psk_cb, ssl_psk_context, disableDefaultTrustStore
* 4 means no protos, protos_len
* 6 means support public key pinning
*/
int struct_version;

Expand All @@ -1095,7 +1096,10 @@ typedef struct
/** The password to load the client's privateKey if encrypted. */
const char* privateKeyPassword;

/** This setting points to the file in PEM format containing the server's public key, can be used public key pinning*/
/**
* This setting points to the file in PEM format containing the server's public key, can be used public key pinning
* Exists only if struct_version >= 6
* */
const char* publicKey;

/**
Expand Down Expand Up @@ -1179,7 +1183,7 @@ typedef struct
unsigned int protos_len;
} MQTTAsync_SSLOptions;

#define MQTTAsync_SSLOptions_initializer { {'M', 'Q', 'T', 'S'}, 5, NULL, NULL, NULL, NULL, NULL, NULL, 1, MQTT_SSL_VERSION_DEFAULT, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0 }
#define MQTTAsync_SSLOptions_initializer { {'M', 'Q', 'T', 'S'}, 6, NULL, NULL, NULL, NULL, NULL, NULL, 1, MQTT_SSL_VERSION_DEFAULT, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0 }

/** Utility structure where name/value pairs are needed */
typedef struct
Expand Down
5 changes: 4 additions & 1 deletion src/MQTTClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,10 @@ typedef struct
/** The password to load the client's privateKey if encrypted. */
const char* privateKeyPassword;

/** This setting points to the file in PEM format containing the server's public key, can be used public key pinning*/
/**
* This setting points to the file in PEM format containing the server's public key, can be used public key pinning
* Exists only if struct_version >= 6
* */
const char* publicKey;

/**
Expand Down

0 comments on commit 5e5b53c

Please sign in to comment.