Skip to content

Commit

Permalink
Rewrite HTTP GET polling task to use mbedtls library
Browse files Browse the repository at this point in the history
The http_get task has been rewritten to use mbedtls instead of BearSSL.
I'm seeing better luck with this library's success rate, although it
still fails on x508 certificate verification intermittently.
  • Loading branch information
trentrand committed Nov 24, 2020
1 parent adf29ba commit 629f4f0
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 302 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ ESPTOOL_ARGS+=-fs 4MB
EXTRA_CFLAGS+=-I./lib/esp-gdbstub/include
EXTRA_LDFLAGS+=-L./lib/esp-gdbstub/lib

EXTRA_COMPONENTS = extras/bearssl
EXTRA_CFLAGS +=-DCONFIG_EPOCH_TIME=$(shell date --utc '+%s')
EXTRA_COMPONENTS = extras/mbedtls

include ./lib/esp-open-rtos/common.mk

Expand Down
79 changes: 0 additions & 79 deletions src/BearSSLTrustAnchors.h

This file was deleted.

44 changes: 44 additions & 0 deletions src/cert.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* This is the CA certificate for the CA trust chain of
www.howsmyssl.com in PEM format, as dumped via:
openssl s_client -showcerts -connect www.howsmyssl.com:443 </dev/null
The CA cert is the last cert in the chain output by the server.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>

/*
* 1 s:C = BE, O = GlobalSign nv-sa, CN = GlobalSign CloudSSL CA - SHA256 - G3
* i:C = BE, O = GlobalSign nv-sa, OU = Root CA, CN = GlobalSign Root CA
*/
const char *server_root_cert = "-----BEGIN CERTIFICATE-----\r\n"
"MIIEizCCA3OgAwIBAgIORvCM288sVGbvMwHdXzQwDQYJKoZIhvcNAQELBQAwVzEL\r\n"
"MAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsT\r\n"
"B1Jvb3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw0xNTA4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