Skip to content

Commit 554c75c

Browse files
authored
Merge pull request #133 from tmobile/tmo-make-json-work-with-cert-store
Fixed json to work with cert store certs
2 parents 2b88be9 + 867764a commit 554c75c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

samples/tmo_shell/src/tmo_http_request.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ LOG_MODULE_REGISTER(tmo_http_request, LOG_LEVEL_DBG);
1919
#include "ca_certificate.h"
2020
#include "tmo_web_demo.h"
2121
#include "tmo_shell.h"
22+
#include "tmo_certs.h"
2223

2324
#if CONFIG_MODEM
2425
#include <zephyr/drivers/modem/murata-1sc.h>
@@ -181,9 +182,12 @@ void tmo_http_json()
181182

182183
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS)
183184
if (tls) {
184-
tls_credential_delete(CA_CERTIFICATE_TAG, TLS_CREDENTIAL_CA_CERTIFICATE);
185-
tls_credential_add(CA_CERTIFICATE_TAG, TLS_CREDENTIAL_CA_CERTIFICATE,
186-
entrust_g2, sizeof(entrust_g2));
185+
186+
if (!ca_cert_sz) {
187+
tls_credential_delete(CA_CERTIFICATE_TAG, TLS_CREDENTIAL_CA_CERTIFICATE);
188+
tls_credential_add(CA_CERTIFICATE_TAG, TLS_CREDENTIAL_CA_CERTIFICATE,
189+
entrust_g2, sizeof(entrust_g2));
190+
}
187191

188192
sock = zsock_socket_ext(res->ai_family, res->ai_socktype, IPPROTO_TLS_1_2, iface);
189193
} else
@@ -208,11 +212,12 @@ void tmo_http_json()
208212

209213
zsock_setsockopt(sock, SOL_TLS, TLS_HOSTNAME,
210214
host, strlen(host) + 1);
211-
// printf("zsock_setsockopt returned %d (errno = %d)\n", ret, errno);
212215
}
213216
#endif
217+
#if CONFIG_MODEM
214218
int tls_verify_val = TLS_PEER_VERIFY_NONE;
215219
zsock_setsockopt(sock, SOL_TLS, TLS_PEER_VERIFY, &tls_verify_val, sizeof(tls_verify_val));
220+
#endif
216221
//Now connect the socket
217222
ret = zsock_connect(sock, res->ai_addr, res->ai_addrlen);
218223

0 commit comments

Comments
 (0)