File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -409,8 +409,13 @@ bool mgos_wifi_dev_sta_setup(const struct mgos_config_wifi_sta *cfg) {
409
409
LOG (LL_ERROR , ("Failed to read %s" , cfg -> ca_cert ));
410
410
goto out ;
411
411
}
412
+ /* For mbedTLS to parse certificate as PEM, mbedtls_x509_crt_parse needs
413
+ * teh blob to be NUL terminated and NUL byte included in the blob length.
414
+ * Luckily, cs_read_file is nice enough to NUL-terminate the data for us
415
+ * (just in case) though it returns size without the NUL.
416
+ * Hence the len + 1 below. */
412
417
esp_wifi_sta_wpa2_ent_set_ca_cert ((unsigned char * ) s_ca_cert_pem ,
413
- (int ) len );
418
+ (int ) len + 1 );
414
419
} else {
415
420
esp_wifi_sta_wpa2_ent_clear_ca_cert ();
416
421
}
@@ -430,8 +435,8 @@ bool mgos_wifi_dev_sta_setup(const struct mgos_config_wifi_sta *cfg) {
430
435
goto out ;
431
436
}
432
437
esp_wifi_sta_wpa2_ent_set_cert_key (
433
- (unsigned char * ) s_cert_pem , (int ) cert_len ,
434
- (unsigned char * ) s_key_pem , (int ) key_len ,
438
+ (unsigned char * ) s_cert_pem , (int ) cert_len + 1 ,
439
+ (unsigned char * ) s_key_pem , (int ) key_len + 1 ,
435
440
NULL /* private_key_passwd */ , 0 /* private_key_passwd_len */ );
436
441
} else {
437
442
esp_wifi_sta_wpa2_ent_clear_cert_key ();
You can’t perform that action at this time.
0 commit comments