Commit c388f1a1 authored by Lucas Dietrich's avatar Lucas Dietrich Committed by Carles Cufi
Browse files

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: default avatarLucas Dietrich <ld.adecy@gmail.com>
parent 42cd204d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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. */
+9 −0
Original line number Diff line number Diff line
@@ -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) {