|
9 | 9 |
|
10 | 10 | #include <zephyr.h> |
11 | 11 | #include <sys/reboot.h> |
12 | | -#include <modem/modem_key_mgmt.h> |
13 | 12 | #include <net/fota_download.h> |
14 | 13 |
|
15 | 14 | #include "fota.h" |
16 | 15 | #include "mosh_print.h" |
17 | 16 |
|
18 | | -#define MOSH_FOTA_US_TLS_SECURITY_TAG 4242424 |
19 | | - |
20 | | -static const char us_root_ca_cert[] = { |
21 | | -#include "cert/Baltimore-CyberTrust-Root" |
22 | | -}; |
23 | | - |
24 | 17 | static void reboot_timer_handler(struct k_timer *dummy) |
25 | 18 | { |
26 | 19 | sys_reboot(SYS_REBOOT_WARM); |
@@ -65,54 +58,12 @@ static void fota_download_callback(const struct fota_download_evt *evt) |
65 | 58 | } |
66 | 59 | } |
67 | 60 |
|
68 | | -static bool fota_us_ca_cert_exists(void) |
69 | | -{ |
70 | | - int err; |
71 | | - bool exists; |
72 | | - |
73 | | - err = modem_key_mgmt_exists(MOSH_FOTA_US_TLS_SECURITY_TAG, |
74 | | - MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN, |
75 | | - &exists); |
76 | | - |
77 | | - if (!err && exists) { |
78 | | - return true; |
79 | | - } else { |
80 | | - return false; |
81 | | - } |
82 | | -} |
83 | | - |
84 | | -static int fota_write_us_ca_cert(void) |
85 | | -{ |
86 | | - return modem_key_mgmt_write(MOSH_FOTA_US_TLS_SECURITY_TAG, |
87 | | - MODEM_KEY_MGMT_CRED_TYPE_CA_CHAIN, |
88 | | - us_root_ca_cert, sizeof(us_root_ca_cert)); |
89 | | -} |
90 | | - |
91 | 61 | int fota_init(void) |
92 | 62 | { |
93 | | - int err; |
94 | | - |
95 | | - if (!fota_us_ca_cert_exists()) { |
96 | | - err = fota_write_us_ca_cert(); |
97 | | - if (err) { |
98 | | - printk("Failed to write US server root CA to modem, error %d\n", |
99 | | - err); |
100 | | - } |
101 | | - } |
102 | | - |
103 | 63 | return fota_download_init(&fota_download_callback); |
104 | 64 | } |
105 | 65 |
|
106 | 66 | int fota_start(const char *host, const char *file) |
107 | 67 | { |
108 | | - int sec_tag; |
109 | | - |
110 | | - if (strstr(host, "us") != 0) { |
111 | | - /* The US server uses a different root CA. */ |
112 | | - sec_tag = MOSH_FOTA_US_TLS_SECURITY_TAG; |
113 | | - } else { |
114 | | - sec_tag = CONFIG_NRF_CLOUD_SEC_TAG; |
115 | | - } |
116 | | - |
117 | | - return fota_download_start(host, file, sec_tag, 0, 0); |
| 68 | + return fota_download_start(host, file, CONFIG_NRF_CLOUD_SEC_TAG, 0, 0); |
118 | 69 | } |
0 commit comments