@@ -40,20 +40,40 @@ LOG_MODULE_REGISTER(mender_stm32l4a6_zephyr_example, LOG_LEVEL_INF);
40
40
#include <zephyr/llext/buf_loader.h>
41
41
#endif /* CONFIG_LLEXT */
42
42
43
+ #ifdef CONFIG_NET_SOCKETS_SOCKOPT_TLS
44
+ #include <zephyr/net/tls_credentials.h>
45
+ #endif /* CONFIG_NET_SOCKETS_SOCKOPT_TLS */
46
+
43
47
/*
44
48
* Amazon Root CA 1 certificate, retrieved from https://www.amazontrust.com/repository in DER format.
45
49
* It is converted to include file in application CMakeLists.txt.
46
50
*/
47
- #if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS )
48
- #include <zephyr/net/tls_credentials.h>
49
- #if defined(CONFIG_TLS_CREDENTIAL_FILENAMES )
50
- static const unsigned char ca_certificate [] = "AmazonRootCA1.cer" ;
51
+ #ifdef CONFIG_NET_SOCKETS_SOCKOPT_TLS
52
+ #ifdef CONFIG_TLS_CREDENTIAL_FILENAMES
53
+ static const unsigned char ca_certificate_primary [] = "AmazonRootCA1.der" ;
54
+ #else
55
+ static const unsigned char ca_certificate_primary [] = {
56
+ #include "AmazonRootCA1.der.inc"
57
+ };
58
+ #endif /* CONFIG_TLS_CREDENTIAL_FILENAMES */
59
+ #endif /* CONFIG_NET_SOCKETS_SOCKOPT_TLS */
60
+
61
+ /*
62
+ * Google Trust Services Root R4 certificate, retrieved from https://pki.goog/repository in DER format.
63
+ * It is converted to include file in application CMakeLists.txt.
64
+ * This secondary Root CA certificate is to be used if the device is connected to a free hosted Mender account (for which artifacts are saved on a Cloudflare server instead of the Amazon S3 storage)
65
+ */
66
+ #ifdef CONFIG_NET_SOCKETS_SOCKOPT_TLS
67
+ #if (0 != CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_SECONDARY )
68
+ #ifdef CONFIG_TLS_CREDENTIAL_FILENAMES
69
+ static const unsigned char ca_certificate_secondary [] = "GoogleTrustServicesR4.der" ;
51
70
#else
52
- static const unsigned char ca_certificate [] = {
53
- #include "AmazonRootCA1.cer .inc"
71
+ static const unsigned char ca_certificate_secondary [] = {
72
+ #include "GoogleTrustServicesR4.der .inc"
54
73
};
55
- #endif
56
- #endif
74
+ #endif /* CONFIG_TLS_CREDENTIAL_FILENAMES */
75
+ #endif /* (0 != CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_SECONDARY) */
76
+ #endif /* CONFIG_NET_SOCKETS_SOCKOPT_TLS */
57
77
58
78
#include "mender-client.h"
59
79
#include "mender-configure.h"
@@ -504,10 +524,17 @@ main(void) {
504
524
/* Wait until the network interface is operational */
505
525
k_event_wait_all (& mender_client_events , MENDER_CLIENT_EVENT_NETWORK_UP , false, K_FOREVER );
506
526
507
- #if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS )
508
- /* Initialize certificate */
509
- tls_credential_add (CONFIG_MENDER_NET_CA_CERTIFICATE_TAG , TLS_CREDENTIAL_CA_CERTIFICATE , ca_certificate , sizeof (ca_certificate ));
510
- #endif
527
+ #ifdef CONFIG_NET_SOCKETS_SOCKOPT_TLS
528
+ /* Initialize certificate(s) */
529
+ assert (0
530
+ == tls_credential_add (
531
+ CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_PRIMARY , TLS_CREDENTIAL_CA_CERTIFICATE , ca_certificate_primary , sizeof (ca_certificate_primary )));
532
+ #if (0 != CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_SECONDARY )
533
+ assert (0
534
+ == tls_credential_add (
535
+ CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_SECONDARY , TLS_CREDENTIAL_CA_CERTIFICATE , ca_certificate_secondary , sizeof (ca_certificate_secondary )));
536
+ #endif /* (0 != CONFIG_MENDER_NET_CA_CERTIFICATE_TAG_SECONDARY) */
537
+ #endif /* CONFIG_NET_SOCKETS_SOCKOPT_TLS */
511
538
512
539
/* Read base MAC address of the device */
513
540
char mac_address [18 ];
0 commit comments