net: mqtt: Add support for TLS option TLS_CERT_NOCOPY
Add an option in MQTT client context to take advantage of the "TLS_CERT_NOCOPY" option when using TLS socket transport. Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
This commit is contained in:
parent
4e103bcb20
commit
0a0e9079c3
2 changed files with 12 additions and 0 deletions
|
@ -354,6 +354,9 @@ struct mqtt_sec_config {
|
|||
* May be NULL to skip hostname verification.
|
||||
*/
|
||||
const char *hostname;
|
||||
|
||||
/** Indicates the preference for copying certificates to the heap. */
|
||||
int cert_nocopy;
|
||||
};
|
||||
|
||||
/** @brief MQTT transport type. */
|
||||
|
|
|
@ -78,6 +78,15 @@ int mqtt_client_tls_connect(struct mqtt_client *client)
|
|||
}
|
||||
}
|
||||
|
||||
if (tls_config->cert_nocopy != TLS_CERT_NOCOPY_NONE) {
|
||||
ret = zsock_setsockopt(client->transport.tls.sock, SOL_TLS,
|
||||
TLS_CERT_NOCOPY, &tls_config->cert_nocopy,
|
||||
sizeof(tls_config->cert_nocopy));
|
||||
if (ret < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
size_t peer_addr_size = sizeof(struct sockaddr_in6);
|
||||
|
||||
if (broker->sa_family == AF_INET) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue