first commit
This commit is contained in:
@@ -0,0 +1,379 @@
|
||||
// GxEPD2_WiFi_CertStore_Loader : Display Library example for SPI e-paper panels from Dalian Good Display and boards from Waveshare.
|
||||
// Requires HW SPI and Adafruit_GFX. Caution: the e-paper panels require 3.3V supply AND data lines!
|
||||
//
|
||||
// Display Library based on Demo Example from Good Display: https://www.good-display.com/companyfile/32/
|
||||
//
|
||||
// Author: Jean-Marc Zingg
|
||||
//
|
||||
// Version: see library.properties
|
||||
//
|
||||
// Library: https://github.com/ZinggJM/GxEPD2
|
||||
|
||||
// Supporting Arduino Forum Topics (closed, read only):
|
||||
// Good Display ePaper for Arduino: https://forum.arduino.cc/t/good-display-epaper-for-arduino/419657
|
||||
// Waveshare e-paper displays with SPI: https://forum.arduino.cc/t/waveshare-e-paper-displays-with-spi/467865
|
||||
//
|
||||
// Add new topics in https://forum.arduino.cc/c/using-arduino/displays/23 for new questions and issues
|
||||
//
|
||||
// This example is used to download the https certificate archive to LittleFS for ESP8266 WiFiClientSecure cert store
|
||||
//
|
||||
// See also https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266WiFi/examples/BearSSL_CertStore
|
||||
//
|
||||
// If you need an updated certs.ar, take a look at subdirectory update_certs
|
||||
// update_certs needs an openssl commandline tool. I downloaded it from https://kb.firedaemon.com/support/solutions/articles/4000121705
|
||||
//
|
||||
// NOTE: this utility example is only useful for ESP8266
|
||||
|
||||
#if defined(ESP32)
|
||||
#include "SPIFFS.h"
|
||||
// set formatOnFail = true for initial format of ESP32 SPIFFS (e.g. if error occured)
|
||||
const bool formatOnFail = false;
|
||||
#endif
|
||||
|
||||
#include <FS.h>
|
||||
|
||||
#if defined (ESP8266)
|
||||
#include <LittleFS.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#endif
|
||||
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
const char* ssid = "........";
|
||||
const char* password = "........";
|
||||
const int httpPort = 80;
|
||||
const int httpsPort = 443;
|
||||
|
||||
// http://cacerts.digicert.com/DigiCertTLSRSASHA2562020CA1-1.crt
|
||||
// CN: DigiCert TLS RSA SHA256 2020 CA1 => name: DigiCert_TLS_RSA_SHA256_2020_CA1
|
||||
// not valid before: 2021-04-14 00:00:00
|
||||
// not valid after: 2031-04-13 23:59:59
|
||||
const char cert_DigiCert_TLS_RSA_SHA256_2020_CA1 [] PROGMEM = R"CERT(
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEvjCCA6agAwIBAgIQBtjZBNVYQ0b2ii+nVCJ+xDANBgkqhkiG9w0BAQsFADBh
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
|
||||
QTAeFw0yMTA0MTQwMDAwMDBaFw0zMTA0MTMyMzU5NTlaME8xCzAJBgNVBAYTAlVT
|
||||
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxKTAnBgNVBAMTIERpZ2lDZXJ0IFRMUyBS
|
||||
U0EgU0hBMjU2IDIwMjAgQ0ExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
|
||||
AQEAwUuzZUdwvN1PWNvsnO3DZuUfMRNUrUpmRh8sCuxkB+Uu3Ny5CiDt3+PE0J6a
|
||||
qXodgojlEVbbHp9YwlHnLDQNLtKS4VbL8Xlfs7uHyiUDe5pSQWYQYE9XE0nw6Ddn
|
||||
g9/n00tnTCJRpt8OmRDtV1F0JuJ9x8piLhMbfyOIJVNvwTRYAIuE//i+p1hJInuW
|
||||
raKImxW8oHzf6VGo1bDtN+I2tIJLYrVJmuzHZ9bjPvXj1hJeRPG/cUJ9WIQDgLGB
|
||||
Afr5yjK7tI4nhyfFK3TUqNaX3sNk+crOU6JWvHgXjkkDKa77SU+kFbnO8lwZV21r
|
||||
eacroicgE7XQPUDTITAHk+qZ9QIDAQABo4IBgjCCAX4wEgYDVR0TAQH/BAgwBgEB
|
||||
/wIBADAdBgNVHQ4EFgQUt2ui6qiqhIx56rTaD5iyxZV2ufQwHwYDVR0jBBgwFoAU
|
||||
A95QNVbRTLtm8KPiGxvDl7I90VUwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQG
|
||||
CCsGAQUFBwMBBggrBgEFBQcDAjB2BggrBgEFBQcBAQRqMGgwJAYIKwYBBQUHMAGG
|
||||
GGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBABggrBgEFBQcwAoY0aHR0cDovL2Nh
|
||||
Y2VydHMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0R2xvYmFsUm9vdENBLmNydDBCBgNV
|
||||
HR8EOzA5MDegNaAzhjFodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGlnaUNlcnRH
|
||||
bG9iYWxSb290Q0EuY3JsMD0GA1UdIAQ2MDQwCwYJYIZIAYb9bAIBMAcGBWeBDAEB
|
||||
MAgGBmeBDAECATAIBgZngQwBAgIwCAYGZ4EMAQIDMA0GCSqGSIb3DQEBCwUAA4IB
|
||||
AQCAMs5eC91uWg0Kr+HWhMvAjvqFcO3aXbMM9yt1QP6FCvrzMXi3cEsaiVi6gL3z
|
||||
ax3pfs8LulicWdSQ0/1s/dCYbbdxglvPbQtaCdB73sRD2Cqk3p5BJl+7j5nL3a7h
|
||||
qG+fh/50tx8bIKuxT8b1Z11dmzzp/2n3YWzW2fP9NsarA4h20ksudYbj/NhVfSbC
|
||||
EXffPgK2fPOre3qGNm+499iTcc+G33Mw+nur7SpZyEKEOxEXGlLzyQ4UfaJbcme6
|
||||
ce1XR2bFuAJKZTRei9AqPCCcUZlM51Ke92sRKw2Sfh3oius2FkOH6ipjv3U/697E
|
||||
A7sKPPcw7+uvTPyLNhBzPvOk
|
||||
-----END CERTIFICATE-----
|
||||
)CERT";
|
||||
|
||||
// https://raw.githubusercontent.com
|
||||
// issued by DigiCert Inc : DigiCert TLS RSA SHA256 2020 CA1
|
||||
// not valid before: Fri, 18 Mar 2022 00:00:00 GMT
|
||||
// not valid after: Tue, 21 Mar 2023 23:59:59 GMT
|
||||
const char github_io_chain_pem_first [] PROGMEM = R"CERT(
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIHEzCCBfugAwIBAgIQC44ztdGGen6l0VAu1+MWiTANBgkqhkiG9w0BAQsFADBP
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMSkwJwYDVQQDEyBE
|
||||
aWdpQ2VydCBUTFMgUlNBIFNIQTI1NiAyMDIwIENBMTAeFw0yMjAzMTgwMDAwMDBa
|
||||
Fw0yMzAzMjEyMzU5NTlaMGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9y
|
||||
bmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRUwEwYDVQQKEwxHaXRIdWIsIElu
|
||||
Yy4xFDASBgNVBAMMCyouZ2l0aHViLmlvMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
|
||||
MIIBCgKCAQEAxgDppBtMFl4zNvBbWAdr21IwcskxdMU/SkxYK/ZAXFrRIPcoZR15
|
||||
5DCrzTevHMUNLhCJqL8mMFidKOz4cZjhPn5sxjUCe/sPNvaiXm8cGUwzFlAYK1MY
|
||||
dM+wepJKcT/qK8RegSIEbk/6qU5Bmh558RSCGuIJj3E85C0fRVdA+zXHP5GkuuB4
|
||||
VEXYzM2oz5KmgXIdBYFydjyK9LNO5nc/Z2Bc7JppCripRHfht3OR1Bf4JFYBuEJE
|
||||
vE4E1FGxwhZzqA/F6ZTRNb+qhQgRfY3HNdbhv5/HRRQZY4H5V6F9MsO0RAHrz30A
|
||||
QtB10paU9KOvxZqA/CEJTAdiYDQKAADitwIDAQABo4ID0TCCA80wHwYDVR0jBBgw
|
||||
FoAUt2ui6qiqhIx56rTaD5iyxZV2ufQwHQYDVR0OBBYEFNPlHIi+YXl95r64oS2D
|
||||
0v2+1mFkMHsGA1UdEQR0MHKCCyouZ2l0aHViLmlvggpnaXRodWIuY29tggwqLmdp
|
||||
dGh1Yi5jb22CDnd3dy5naXRodWIuY29tgglnaXRodWIuaW+CFWdpdGh1YnVzZXJj
|
||||
b250ZW50LmNvbYIXKi5naXRodWJ1c2VyY29udGVudC5jb20wDgYDVR0PAQH/BAQD
|
||||
AgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjCBjwYDVR0fBIGHMIGE
|
||||
MECgPqA8hjpodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGlnaUNlcnRUTFNSU0FT
|
||||
SEEyNTYyMDIwQ0ExLTQuY3JsMECgPqA8hjpodHRwOi8vY3JsNC5kaWdpY2VydC5j
|
||||
b20vRGlnaUNlcnRUTFNSU0FTSEEyNTYyMDIwQ0ExLTQuY3JsMD4GA1UdIAQ3MDUw
|
||||
MwYGZ4EMAQICMCkwJwYIKwYBBQUHAgEWG2h0dHA6Ly93d3cuZGlnaWNlcnQuY29t
|
||||
L0NQUzB/BggrBgEFBQcBAQRzMHEwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRp
|
||||
Z2ljZXJ0LmNvbTBJBggrBgEFBQcwAoY9aHR0cDovL2NhY2VydHMuZGlnaWNlcnQu
|
||||
Y29tL0RpZ2lDZXJ0VExTUlNBU0hBMjU2MjAyMENBMS0xLmNydDAJBgNVHRMEAjAA
|
||||
MIIBfwYKKwYBBAHWeQIEAgSCAW8EggFrAWkAdgDoPtDaPvUGNTLnVyi8iWvJA9PL
|
||||
0RFr7Otp4Xd9bQa9bgAAAX+dgO+dAAAEAwBHMEUCIQDOV8Qe7mebG+hhf+MfzEEF
|
||||
2i0lNIO83vUTxkMREz/eMwIgKp3ZLFVMP2hz+1DAYPhmKvdWT3kTKWeeZxSHUEtm
|
||||
f88AdgA1zxkbv7FsV78PrUxtQsu7ticgJlHqP+Eq76gDwzvWTAAAAX+dgO/rAAAE
|
||||
AwBHMEUCIDAKos+w1Y1esfHWzcjREKA0m/fEoyMxA8Cj5EZETZziAiEAkxIcc6ZB
|
||||
3d7pHTI2w1yuRp1s6uciDTU/ICZ5yEvuFtwAdwC3Pvsk35xNunXyOcW6WPRsXfxC
|
||||
z3qfNcSeHQmBJe20mQAAAX+dgO/PAAAEAwBIMEYCIQDDYK04bMarexB4cqaAhnUF
|
||||
FItaejcjp7CeW+YtF70CzAIhAK5Fy7ARpPdjNoaSWuG1NzNZbj6DPfwdsFOZnoBq
|
||||
4GLhMA0GCSqGSIb3DQEBCwUAA4IBAQBokieSf5eLa7o62sPf9ihHuvIPoligvH1r
|
||||
gxFf6+kgsz+EwtF80Tb0ZR2DC7O2HSi0JGiihPgKO/3bXHZUc9cc4NkL7J842yFI
|
||||
rRwPHABMq2nLq7LCuGdJn+2tG76DAOXCtHMQ6XfuAq1FoPbtxXdWzynOJdDelPC6
|
||||
Qv3v3sMH6gJML1vW3OmeSUIncu686uDTs6E95BIuZ8eOjBjxZ7GfQv54RQU6oiMf
|
||||
bYVRSYaNfnS0VkPlwcR9Ubhx9wEuG4GuDus7OWItwFqm2c3peKQQK8+2CDMUHDUC
|
||||
QafDHvXcWeRdqQouCQC1tDlRAzPLKTcLD6EVltnPR5HQITRvHVgm
|
||||
-----END CERTIFICATE-----
|
||||
)CERT";
|
||||
const char github_io_chain_pem_second [] PROGMEM = R"CERT(
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEvjCCA6agAwIBAgIQBtjZBNVYQ0b2ii+nVCJ+xDANBgkqhkiG9w0BAQsFADBh
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
|
||||
QTAeFw0yMTA0MTQwMDAwMDBaFw0zMTA0MTMyMzU5NTlaME8xCzAJBgNVBAYTAlVT
|
||||
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxKTAnBgNVBAMTIERpZ2lDZXJ0IFRMUyBS
|
||||
U0EgU0hBMjU2IDIwMjAgQ0ExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
|
||||
AQEAwUuzZUdwvN1PWNvsnO3DZuUfMRNUrUpmRh8sCuxkB+Uu3Ny5CiDt3+PE0J6a
|
||||
qXodgojlEVbbHp9YwlHnLDQNLtKS4VbL8Xlfs7uHyiUDe5pSQWYQYE9XE0nw6Ddn
|
||||
g9/n00tnTCJRpt8OmRDtV1F0JuJ9x8piLhMbfyOIJVNvwTRYAIuE//i+p1hJInuW
|
||||
raKImxW8oHzf6VGo1bDtN+I2tIJLYrVJmuzHZ9bjPvXj1hJeRPG/cUJ9WIQDgLGB
|
||||
Afr5yjK7tI4nhyfFK3TUqNaX3sNk+crOU6JWvHgXjkkDKa77SU+kFbnO8lwZV21r
|
||||
eacroicgE7XQPUDTITAHk+qZ9QIDAQABo4IBgjCCAX4wEgYDVR0TAQH/BAgwBgEB
|
||||
/wIBADAdBgNVHQ4EFgQUt2ui6qiqhIx56rTaD5iyxZV2ufQwHwYDVR0jBBgwFoAU
|
||||
A95QNVbRTLtm8KPiGxvDl7I90VUwDgYDVR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQG
|
||||
CCsGAQUFBwMBBggrBgEFBQcDAjB2BggrBgEFBQcBAQRqMGgwJAYIKwYBBQUHMAGG
|
||||
GGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBABggrBgEFBQcwAoY0aHR0cDovL2Nh
|
||||
Y2VydHMuZGlnaWNlcnQuY29tL0RpZ2lDZXJ0R2xvYmFsUm9vdENBLmNydDBCBgNV
|
||||
HR8EOzA5MDegNaAzhjFodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGlnaUNlcnRH
|
||||
bG9iYWxSb290Q0EuY3JsMD0GA1UdIAQ2MDQwCwYJYIZIAYb9bAIBMAcGBWeBDAEB
|
||||
MAgGBmeBDAECATAIBgZngQwBAgIwCAYGZ4EMAQIDMA0GCSqGSIb3DQEBCwUAA4IB
|
||||
AQCAMs5eC91uWg0Kr+HWhMvAjvqFcO3aXbMM9yt1QP6FCvrzMXi3cEsaiVi6gL3z
|
||||
ax3pfs8LulicWdSQ0/1s/dCYbbdxglvPbQtaCdB73sRD2Cqk3p5BJl+7j5nL3a7h
|
||||
qG+fh/50tx8bIKuxT8b1Z11dmzzp/2n3YWzW2fP9NsarA4h20ksudYbj/NhVfSbC
|
||||
EXffPgK2fPOre3qGNm+499iTcc+G33Mw+nur7SpZyEKEOxEXGlLzyQ4UfaJbcme6
|
||||
ce1XR2bFuAJKZTRei9AqPCCcUZlM51Ke92sRKw2Sfh3oius2FkOH6ipjv3U/697E
|
||||
A7sKPPcw7+uvTPyLNhBzPvOk
|
||||
-----END CERTIFICATE-----
|
||||
)CERT";
|
||||
const char github_io_chain_pem_third [] PROGMEM = R"CERT(
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
|
||||
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
|
||||
QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
|
||||
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
|
||||
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
|
||||
9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
|
||||
CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
|
||||
nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
|
||||
43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
|
||||
T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
|
||||
gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
|
||||
BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
|
||||
TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
|
||||
DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
|
||||
hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
|
||||
06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
|
||||
PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
|
||||
YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
|
||||
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
|
||||
-----END CERTIFICATE-----
|
||||
)CERT";
|
||||
|
||||
const char* host_rawcontent = "raw.githubusercontent.com";
|
||||
const char* path_certstore_raw = "/ZinggJM/GxEPD2/master/examples/GxEPD2_WiFi_CertStore_Loader/";
|
||||
const char* fp_github_io = "8F 0E 79 24 71 C5 A7 D2 A7 46 76 30 C1 3C B7 2A 13 B0 01 B2"; // as of 29.7.2022
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println("GxEPD2_WiFi_CertStore_Loader");
|
||||
|
||||
#ifdef RE_INIT_NEEDED
|
||||
WiFi.persistent(true);
|
||||
WiFi.mode(WIFI_STA); // switch off AP
|
||||
WiFi.setAutoConnect(true);
|
||||
WiFi.setAutoReconnect(true);
|
||||
WiFi.disconnect();
|
||||
#endif
|
||||
|
||||
if (!WiFi.getAutoConnect() || ( WiFi.getMode() != WIFI_STA) || ((WiFi.SSID() != ssid) && String(ssid) != "........"))
|
||||
{
|
||||
Serial.println();
|
||||
Serial.print("WiFi.getAutoConnect()=");
|
||||
Serial.println(WiFi.getAutoConnect());
|
||||
Serial.print("WiFi.SSID()=");
|
||||
Serial.println(WiFi.SSID());
|
||||
WiFi.mode(WIFI_STA); // switch off AP
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
WiFi.begin(ssid, password);
|
||||
}
|
||||
int ConnectTimeout = 30; // 15 seconds
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
Serial.print(WiFi.status());
|
||||
if (--ConnectTimeout <= 0)
|
||||
{
|
||||
Serial.println();
|
||||
Serial.println("WiFi connect timeout");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Serial.println();
|
||||
Serial.println("WiFi connected");
|
||||
|
||||
// Print the IP address
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
setClock();
|
||||
|
||||
#if defined (ESP8266)
|
||||
LittleFS.begin();
|
||||
Serial.println("LittleFS started");
|
||||
//LittleFS.remove("certs_list.txt"); // was used for test
|
||||
LittleFS.remove("certs.ar");
|
||||
LittleFS.remove("certs.idx");
|
||||
#elif defined (ESP32)
|
||||
SPIFFS.begin();
|
||||
Serial.println("SPIFFS started");
|
||||
//SPIFFS.remove("certs_list.txt"); // was used for test
|
||||
SPIFFS.remove("certs.ar");
|
||||
SPIFFS.remove("certs.idx");
|
||||
#endif
|
||||
listFiles();
|
||||
//downloadFile_HTTPS(host_rawcontent, path_certstore_raw, "certs_list.txt", "certs_list.txt"); // was used for test
|
||||
downloadFile_HTTPS(host_rawcontent, path_certstore_raw, "certs.ar", "certs.ar");
|
||||
listFiles();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
void downloadFile_HTTPS(const char* host, const char* path, const char* filename, const char* target)
|
||||
{
|
||||
// Use WiFiClientSecure class to create TLS connection
|
||||
#if defined (ESP8266)
|
||||
BearSSL::WiFiClientSecure client;
|
||||
BearSSL::X509List cert(cert_DigiCert_TLS_RSA_SHA256_2020_CA1);
|
||||
BearSSL::X509List cert_pem_first(github_io_chain_pem_first);
|
||||
BearSSL::X509List cert_pem_second(github_io_chain_pem_second);
|
||||
BearSSL::X509List cert_pem_third(github_io_chain_pem_third);
|
||||
#else
|
||||
WiFiClientSecure client;
|
||||
#endif
|
||||
Serial.println(); Serial.print("downloading file \""); Serial.print(filename); Serial.println("\"");
|
||||
Serial.print("connecting to "); Serial.println(host);
|
||||
#if defined (ESP8266)
|
||||
//client.setInsecure(); // fallback, currently still works with BearSSL
|
||||
//client.setFingerprint(fp_github_io); // maybe would work until Tue, 21 Mar 2023 23:59:59 GMT
|
||||
//client.setTrustAnchors(&cert_pem_first); // should work until Tue, 21 Mar 2023 23:59:59 GMT
|
||||
//client.setTrustAnchors(&cert_pem_second); // should work until Tue, 21 Mar 2023 23:59:59 GMT
|
||||
//client.setTrustAnchors(&cert_pem_third); // should work until Tue, 21 Mar 2023 23:59:59 GMT
|
||||
client.setTrustAnchors(&cert); // should work until 2031-04-13 23:59:59
|
||||
#elif defined (ESP32)
|
||||
client.setCACert(cert_DigiCert_TLS_RSA_SHA256_2020_CA1);
|
||||
#endif
|
||||
if (!client.connect(host, httpsPort))
|
||||
{
|
||||
Serial.println("connection failed");
|
||||
return;
|
||||
}
|
||||
Serial.print("requesting URL: ");
|
||||
Serial.println(String("https://") + host + path + filename);
|
||||
client.print(String("GET ") + path + filename + " HTTP/1.1\r\n" +
|
||||
"Host: " + host + "\r\n" +
|
||||
"User-Agent: GxEPD2_WiFi_CertStore_Loader\r\n" +
|
||||
"Connection: close\r\n\r\n");
|
||||
Serial.println("request sent");
|
||||
bool ok = false;
|
||||
while (client.connected() || client.available())
|
||||
{
|
||||
String line = client.readStringUntil('\n');
|
||||
if (!ok)
|
||||
{
|
||||
ok = line.startsWith("HTTP/1.1 200 OK");
|
||||
if (ok) Serial.println(line);
|
||||
//if (!ok) Serial.println(line);
|
||||
}
|
||||
if (!ok) Serial.println(line);
|
||||
//Serial.println(line);
|
||||
if (line == "\r")
|
||||
{
|
||||
Serial.println("headers received");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ok) return;
|
||||
uint8_t buffer[512];
|
||||
size_t total = 0;
|
||||
#if defined (ESP8266)
|
||||
fs::File file = LittleFS.open(target, "w+");
|
||||
#elif defined(ESP32)
|
||||
fs::File file = SPIFFS.open(String("/") + target, "w+");
|
||||
#endif
|
||||
if (!file)
|
||||
{
|
||||
Serial.print(target); Serial.println(" open failed");
|
||||
return;
|
||||
}
|
||||
while (client.connected() || client.available())
|
||||
{
|
||||
// this doesn't work as expected, but it helps for long downloads
|
||||
int32_t start = millis();
|
||||
for (int16_t t = 0, dly = 50; t < 20; t++, dly += 50)
|
||||
{
|
||||
if (!(client.connected() || client.available())) break;
|
||||
if (client.available()) break; // read would not recover after having returned 0
|
||||
delay(dly);
|
||||
}
|
||||
if (!(client.connected() || client.available())) break;
|
||||
int32_t elapsed = millis() - start;
|
||||
if (elapsed > 250)
|
||||
{
|
||||
Serial.print("waited for available "); Serial.print(millis() - start); Serial.print(" ms @ "); Serial.println(total);
|
||||
}
|
||||
size_t available = client.available();
|
||||
if (0 == available)
|
||||
{
|
||||
Serial.print("download error: timeout on available() after "); Serial.print(total); Serial.println(" bytes");
|
||||
break; // don't hang forever
|
||||
}
|
||||
size_t fetch = available <= sizeof(buffer) ? available : sizeof(buffer);
|
||||
if (fetch > 0)
|
||||
{
|
||||
size_t got = client.read(buffer, fetch);
|
||||
file.write(buffer, got);
|
||||
total += got;
|
||||
}
|
||||
delay(1); // yield();
|
||||
if (total > 30000) delay(250); // helps for long downloads
|
||||
}
|
||||
file.close();
|
||||
Serial.print("done, "); Serial.print(total); Serial.println(" bytes transferred");
|
||||
}
|
||||
|
||||
// Set time via NTP, as required for x.509 validation
|
||||
void setClock()
|
||||
{
|
||||
configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
|
||||
|
||||
Serial.print("Waiting for NTP time sync: ");
|
||||
time_t now = time(nullptr);
|
||||
while (now < 8 * 3600 * 2)
|
||||
{
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
now = time(nullptr);
|
||||
}
|
||||
Serial.println("");
|
||||
struct tm timeinfo;
|
||||
gmtime_r(&now, &timeinfo);
|
||||
Serial.print("Current time: ");
|
||||
Serial.print(asctime(&timeinfo));
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#if defined(ESP32)
|
||||
|
||||
#include "FS.h"
|
||||
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
|
||||
Serial.printf("Listing directory: %s\r\n", dirname);
|
||||
|
||||
File root = fs.open(dirname);
|
||||
if (!root) {
|
||||
Serial.println("- failed to open directory");
|
||||
return;
|
||||
}
|
||||
if (!root.isDirectory()) {
|
||||
Serial.println(" - not a directory");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = root.openNextFile();
|
||||
while (file) {
|
||||
if (file.isDirectory()) {
|
||||
Serial.print(" DIR : ");
|
||||
Serial.println(file.name());
|
||||
if (levels) {
|
||||
listDir(fs, file.name(), levels - 1);
|
||||
}
|
||||
} else {
|
||||
Serial.print(" FILE: ");
|
||||
Serial.print(file.name());
|
||||
Serial.print("\tSIZE: ");
|
||||
Serial.println(file.size());
|
||||
}
|
||||
file = root.openNextFile();
|
||||
}
|
||||
}
|
||||
|
||||
void listFiles()
|
||||
{
|
||||
listDir(SPIFFS, "/", 0);
|
||||
}
|
||||
|
||||
#elif defined(ESP8266)
|
||||
|
||||
#include <FS.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
/*====================================================================================
|
||||
This sketch contains support functions for the ESP6266 LittleFS filing system
|
||||
|
||||
Created by Bodmer 15th Jan 2017
|
||||
==================================================================================*/
|
||||
|
||||
//====================================================================================
|
||||
// Print a LittleFS directory list (root directory)
|
||||
//====================================================================================
|
||||
|
||||
void listFiles(void) {
|
||||
Serial.println();
|
||||
Serial.println("LittleFS files found:");
|
||||
|
||||
fs::Dir dir = LittleFS.openDir(""); // Root directory
|
||||
String line = "=====================================";
|
||||
uint32_t totalBytes = 0;
|
||||
|
||||
Serial.println(line);
|
||||
Serial.println(" File name Size");
|
||||
Serial.println(line);
|
||||
|
||||
while (dir.next()) {
|
||||
String fileName = dir.fileName();
|
||||
Serial.print(fileName);
|
||||
int spaces = 25 - fileName.length(); // Tabulate nicely
|
||||
while (spaces--) Serial.print(" ");
|
||||
fs::File f = dir.openFile("r");
|
||||
Serial.print(f.size()); Serial.println(" bytes");
|
||||
totalBytes += f.size();
|
||||
}
|
||||
Serial.println(); Serial.print("Total = ");
|
||||
int spaces = 25 - 8; // Tabulate nicely
|
||||
while (spaces--) Serial.print(" ");
|
||||
Serial.print(totalBytes); Serial.println(" bytes");
|
||||
|
||||
Serial.println(line);
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
//====================================================================================
|
||||
|
||||
#else
|
||||
|
||||
void listFiles()
|
||||
{
|
||||
Serial.println("LittleFS listFiles() not implemented");
|
||||
}
|
||||
#endif
|
||||
BIN
libraries/GxEPD2/examples/GxEPD2_WiFi_CertStore_Loader/certs.ar
Normal file
BIN
libraries/GxEPD2/examples/GxEPD2_WiFi_CertStore_Loader/certs.ar
Normal file
Binary file not shown.
@@ -0,0 +1,178 @@
|
||||
Microsoft Windows [Version 10.0.19045.2193]
|
||||
(c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
C:\Users\ZinggJ>cd C:\ZinggJ\ESP8266\BearSSL_CertStore
|
||||
|
||||
C:\ZinggJ\ESP8266\BearSSL_CertStore>path C:\Users\ZinggJ\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1;C:\Users\ZinggJ\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\bin;%PATH%
|
||||
|
||||
C:\ZinggJ\ESP8266\BearSSL_CertStore>python3 certs-from-mozilla.py
|
||||
AC Camerfirma, S.A.:AC Camerfirma SA CIF A82743287:http://www.chambersign.org -> data/ca_000.der
|
||||
AC Camerfirma, S.A.:AC Camerfirma S.A.: -> data/ca_001.der
|
||||
AC Camerfirma, S.A.:AC Camerfirma S.A.: -> data/ca_002.der
|
||||
Actalis:Actalis S.p.A./03358520967: -> data/ca_003.der
|
||||
Amazon Trust Services:Amazon: -> data/ca_004.der
|
||||
Amazon Trust Services:Amazon: -> data/ca_005.der
|
||||
Amazon Trust Services:Amazon: -> data/ca_006.der
|
||||
Amazon Trust Services:Amazon: -> data/ca_007.der
|
||||
Amazon Trust Services:Starfield Technologies, Inc.: -> data/ca_008.der
|
||||
Asseco Data Systems S.A. (previously Unizeto Certum):Unizeto Sp. z o.o.: -> data/ca_009.der
|
||||
Asseco Data Systems S.A. (previously Unizeto Certum):Asseco Data Systems S.A.:Certum Certification Authority -> data/ca_010.der
|
||||
Asseco Data Systems S.A. (previously Unizeto Certum):Unizeto Technologies S.A.:Certum Certification Authority -> data/ca_011.der
|
||||
Asseco Data Systems S.A. (previously Unizeto Certum):Unizeto Technologies S.A.:Certum Certification Authority -> data/ca_012.der
|
||||
Asseco Data Systems S.A. (previously Unizeto Certum):Asseco Data Systems S.A.:Certum Certification Authority -> data/ca_013.der
|
||||
Atos:Atos: -> data/ca_014.der
|
||||
Autoridad de Certificacion Firmaprofesional:: -> data/ca_015.der
|
||||
Autoridad de Certificacion Firmaprofesional:: -> data/ca_016.der
|
||||
Autoridad de Certificación (ANF AC):ANF Autoridad de Certificacion:ANF CA Raiz -> data/ca_017.der
|
||||
Buypass:Buypass AS-983163327: -> data/ca_018.der
|
||||
Buypass:Buypass AS-983163327: -> data/ca_019.der
|
||||
Certainly LLC:Certainly: -> data/ca_020.der
|
||||
Certainly LLC:Certainly: -> data/ca_021.der
|
||||
certSIGN:certSIGN:certSIGN ROOT CA -> data/ca_022.der
|
||||
certSIGN:CERTSIGN SA:certSIGN ROOT CA G2 -> data/ca_023.der
|
||||
China Financial Certification Authority (CFCA):China Financial Certification Authority: -> data/ca_024.der
|
||||
Chunghwa Telecom:Chunghwa Telecom Co., Ltd.:ePKI Root Certification Authority -> data/ca_025.der
|
||||
Chunghwa Telecom:Chunghwa Telecom Co., Ltd.: -> data/ca_026.der
|
||||
Consorci Administració Oberta de Catalunya (Consorci AOC, CATCert):Agencia Catalana de Certificacio (NIF Q-0801176-I):Serveis Publics de Certificacio, Vegeu https://www.catcert.net/verarrel (c)03, Jerarquia Entitats de Certificacio Catalanes -> data/ca_027.der
|
||||
Cybertrust Japan / JCSI:Japan Certification Services, Inc.: -> data/ca_028.der
|
||||
D-Trust:D-Trust GmbH: -> data/ca_029.der
|
||||
D-Trust:D-Trust GmbH: -> data/ca_030.der
|
||||
D-Trust:D-Trust GmbH: -> data/ca_031.der
|
||||
D-Trust:D-Trust GmbH: -> data/ca_032.der
|
||||
D-Trust:D-Trust GmbH: -> data/ca_033.der
|
||||
Deutsche Telekom Security GmbH:T-Systems Enterprise Services GmbH:T-Systems Trust Center -> data/ca_034.der
|
||||
Deutsche Telekom Security GmbH:T-Systems Enterprise Services GmbH:T-Systems Trust Center -> data/ca_035.der
|
||||
Dhimyotis / Certigna:Dhimyotis: -> data/ca_036.der
|
||||
Dhimyotis / Certigna:Dhimyotis:0002 48146308100036 -> data/ca_037.der
|
||||
DigiCert:Baltimore:CyberTrust -> data/ca_038.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_039.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_040.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_041.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_042.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_043.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_044.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_045.der
|
||||
DigiCert:DigiCert, Inc.: -> data/ca_046.der
|
||||
DigiCert:DigiCert, Inc.: -> data/ca_047.der
|
||||
DigiCert:DigiCert, Inc.: -> data/ca_048.der
|
||||
DigiCert:DigiCert, Inc.: -> data/ca_049.der
|
||||
DigiCert:DigiCert Inc:www.digicert.com -> data/ca_050.der
|
||||
DigiCert:Symantec Corporation:Symantec Trust Network -> data/ca_051.der
|
||||
DigiCert:Symantec Corporation:Symantec Trust Network -> data/ca_052.der
|
||||
DigiCert:VeriSign, Inc.:VeriSign Trust Network, (c) 1999 VeriSign, Inc. - For authorized use only -> data/ca_053.der
|
||||
DigiCert:VeriSign, Inc.:VeriSign Trust Network, (c) 1999 VeriSign, Inc. - For authorized use only -> data/ca_054.der
|
||||
DigitalSign - Certificadora Digital, S.A:DigitalSign Certificadora Digital: -> data/ca_055.der
|
||||
DigitalSign - Certificadora Digital, S.A:DigitalSign Certificadora Digital: -> data/ca_056.der
|
||||
Disig, a.s.:Disig a.s.: -> data/ca_057.der
|
||||
e-commerce monitoring GmbH:e-commerce monitoring GmbH: -> data/ca_058.der
|
||||
E-Tugra:E-Tuğra EBG Bilişim Teknolojileri ve Hizmetleri A.Ş.:E-Tugra Sertifikasyon Merkezi -> data/ca_059.der
|
||||
E-Tugra:E-Tugra EBG A.S.:E-Tugra Trust Center -> data/ca_060.der
|
||||
E-Tugra:E-Tugra EBG A.S.:E-Tugra Trust Center -> data/ca_061.der
|
||||
eMudhra Technologies Limited:eMudhra Inc:emSign PKI -> data/ca_062.der
|
||||
eMudhra Technologies Limited:eMudhra Technologies Limited:emSign PKI -> data/ca_063.der
|
||||
eMudhra Technologies Limited:eMudhra Inc:emSign PKI -> data/ca_064.der
|
||||
eMudhra Technologies Limited:eMudhra Technologies Limited:emSign PKI -> data/ca_065.der
|
||||
Entrust:AffirmTrust: -> data/ca_066.der
|
||||
Entrust:AffirmTrust: -> data/ca_067.der
|
||||
Entrust:AffirmTrust: -> data/ca_068.der
|
||||
Entrust:AffirmTrust: -> data/ca_069.der
|
||||
Entrust:Entrust, Inc.:www.entrust.net/CPS is incorporated by reference, (c) 2006 Entrust, Inc. -> data/ca_070.der
|
||||
Entrust:Entrust, Inc.:See www.entrust.net/legal-terms, (c) 2012 Entrust, Inc. - for authorized use only -> data/ca_071.der
|
||||
Entrust:Entrust, Inc.:See www.entrust.net/legal-terms, (c) 2009 Entrust, Inc. - for authorized use only -> data/ca_072.der
|
||||
Entrust:Entrust, Inc.:See www.entrust.net/legal-terms, (c) 2015 Entrust, Inc. - for authorized use only -> data/ca_073.der
|
||||
Entrust:Entrust.net:www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), (c) 1999 Entrust.net Limited -> data/ca_074.der
|
||||
Global Digital Cybersecurity Authority Co., Ltd. (Formerly Guang Dong Certificate Authority (GDCA)):GUANG DONG CERTIFICATE AUTHORITY CO.,LTD.: -> data/ca_075.der
|
||||
GlobalSign nv-sa:GlobalSign:GlobalSign Root CA - R3 -> data/ca_076.der
|
||||
GlobalSign nv-sa:GlobalSign:GlobalSign ECC Root CA - R5 -> data/ca_077.der
|
||||
GlobalSign nv-sa:GlobalSign:GlobalSign Root CA - R6 -> data/ca_078.der
|
||||
GlobalSign nv-sa:GlobalSign nv-sa:Root CA -> data/ca_079.der
|
||||
GlobalSign nv-sa:GlobalSign nv-sa: -> data/ca_080.der
|
||||
GlobalSign nv-sa:GlobalSign nv-sa: -> data/ca_081.der
|
||||
GlobalSign nv-sa:GlobalSign nv-sa: -> data/ca_082.der
|
||||
GlobalSign nv-sa:GlobalSign nv-sa: -> data/ca_083.der
|
||||
GoDaddy:The Go Daddy Group, Inc.:Go Daddy Class 2 Certification Authority -> data/ca_084.der
|
||||
GoDaddy:GoDaddy.com, Inc.: -> data/ca_085.der
|
||||
GoDaddy:Starfield Technologies, Inc.:Starfield Class 2 Certification Authority -> data/ca_086.der
|
||||
GoDaddy:Starfield Technologies, Inc.: -> data/ca_087.der
|
||||
Google Trust Services LLC:GlobalSign:GlobalSign ECC Root CA - R4 -> data/ca_088.der
|
||||
Google Trust Services LLC:GlobalSign:GlobalSign ECC Root CA - R4 -> data/ca_089.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_090.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_091.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_092.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_093.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_094.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_095.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_096.der
|
||||
Google Trust Services LLC:Google Trust Services LLC: -> data/ca_097.der
|
||||
Government of Hong Kong (SAR), Hongkong Post, Certizen:Hongkong Post: -> data/ca_098.der
|
||||
Government of Hong Kong (SAR), Hongkong Post, Certizen:Hongkong Post: -> data/ca_099.der
|
||||
Government of Spain, Autoritat de Certificació de la Comunitat Valenciana (ACCV):ACCV:PKIACCV -> data/ca_100.der
|
||||
Government of Spain, Fábrica Nacional de Moneda y Timbre (FNMT):FNMT-RCM:Ceres -> data/ca_101.der
|
||||
Government of Spain, Fábrica Nacional de Moneda y Timbre (FNMT):FNMT-RCM:AC RAIZ FNMT-RCM -> data/ca_102.der
|
||||
Government of The Netherlands, PKIoverheid (Logius):Staat der Nederlanden: -> data/ca_103.der
|
||||
Government of The Netherlands, PKIoverheid (Logius):Staat der Nederlanden: -> data/ca_104.der
|
||||
Government of Tunisia, Agence National de Certification Electronique / National Digital Certification Agency (ANCE/NDCA):Agence Nationale de Certification Electronique: -> data/ca_105.der
|
||||
Government of Turkey, Kamu Sertifikasyon Merkezi (Kamu SM):Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK:Kamu Sertifikasyon Merkezi - Kamu SM -> data/ca_106.der
|
||||
HARICA:Hellenic Academic and Research Institutions CA: -> data/ca_107.der
|
||||
HARICA:Hellenic Academic and Research Institutions CA: -> data/ca_108.der
|
||||
HARICA:Hellenic Academic and Research Institutions CA: -> data/ca_109.der
|
||||
HARICA:Hellenic Academic and Research Institutions CA: -> data/ca_110.der
|
||||
HARICA:Hellenic Academic and Research Institutions Cert. Authority: -> data/ca_111.der
|
||||
HARICA:Hellenic Academic and Research Institutions Cert. Authority: -> data/ca_112.der
|
||||
IdenTrust Services, LLC:IdenTrust: -> data/ca_113.der
|
||||
IdenTrust Services, LLC:IdenTrust: -> data/ca_114.der
|
||||
Internet Security Research Group:Internet Security Research Group: -> data/ca_115.der
|
||||
Internet Security Research Group:Internet Security Research Group: -> data/ca_116.der
|
||||
iTrusChina Co., Ltd.:iTrusChina Co.,Ltd.: -> data/ca_117.der
|
||||
iTrusChina Co., Ltd.:iTrusChina Co.,Ltd.: -> data/ca_118.der
|
||||
Izenpe S.A.:IZENPE S.A.: -> data/ca_119.der
|
||||
Krajowa Izba Rozliczeniowa S.A. (KIR):Krajowa Izba Rozliczeniowa S.A.: -> data/ca_120.der
|
||||
Microsec Ltd.:Microsec Ltd.: -> data/ca_121.der
|
||||
Microsec Ltd.:Microsec Ltd.: -> data/ca_122.der
|
||||
Microsoft Corporation:Microsoft Corporation: -> data/ca_123.der
|
||||
Microsoft Corporation:Microsoft Corporation: -> data/ca_124.der
|
||||
NAVER Cloud:NAVER BUSINESS PLATFORM Corp.: -> data/ca_125.der
|
||||
Netlock:NetLock Kft.:Tanúsítványkiadók (Certification Services) -> data/ca_126.der
|
||||
Network Solutions:Network Solutions L.L.C.: -> data/ca_127.der
|
||||
OISTE:WISeKey:Copyright (c) 2005, OISTE Foundation Endorsed -> data/ca_128.der
|
||||
OISTE:WISeKey:OISTE Foundation Endorsed -> data/ca_129.der
|
||||
OISTE:WISeKey:OISTE Foundation Endorsed -> data/ca_130.der
|
||||
QuoVadis:QuoVadis Limited: -> data/ca_131.der
|
||||
QuoVadis:QuoVadis Limited: -> data/ca_132.der
|
||||
QuoVadis:QuoVadis Limited: -> data/ca_133.der
|
||||
QuoVadis:QuoVadis Limited: -> data/ca_134.der
|
||||
QuoVadis:QuoVadis Limited: -> data/ca_135.der
|
||||
SECOM Trust Systems CO., LTD.:SECOM Trust.net:Security Communication RootCA1 -> data/ca_136.der
|
||||
SECOM Trust Systems CO., LTD.:SECOM Trust Systems CO.,LTD.: -> data/ca_137.der
|
||||
SECOM Trust Systems CO., LTD.:SECOM Trust Systems CO.,LTD.:Security Communication RootCA2 -> data/ca_138.der
|
||||
SECOM Trust Systems CO., LTD.:SECOM Trust Systems CO.,LTD.: -> data/ca_139.der
|
||||
Sectigo:Comodo CA Limited: -> data/ca_140.der
|
||||
Sectigo:COMODO CA Limited: -> data/ca_141.der
|
||||
Sectigo:COMODO CA Limited: -> data/ca_142.der
|
||||
Sectigo:COMODO CA Limited: -> data/ca_143.der
|
||||
Sectigo:The USERTRUST Network: -> data/ca_144.der
|
||||
Sectigo:The USERTRUST Network: -> data/ca_145.der
|
||||
SecureTrust:SecureTrust Corporation: -> data/ca_146.der
|
||||
SecureTrust:SecureTrust Corporation: -> data/ca_147.der
|
||||
SecureTrust:Trustwave Holdings, Inc.: -> data/ca_148.der
|
||||
SecureTrust:Trustwave Holdings, Inc.: -> data/ca_149.der
|
||||
SecureTrust:Trustwave Holdings, Inc.: -> data/ca_150.der
|
||||
SecureTrust:XRamp Security Services Inc:www.xrampsecurity.com -> data/ca_151.der
|
||||
Shanghai Electronic Certification Authority Co., Ltd.:UniTrust: -> data/ca_152.der
|
||||
Shanghai Electronic Certification Authority Co., Ltd.:UniTrust: -> data/ca_153.der
|
||||
SSL.com:SSL Corporation: -> data/ca_154.der
|
||||
SSL.com:SSL Corporation: -> data/ca_155.der
|
||||
SSL.com:SSL Corporation: -> data/ca_156.der
|
||||
SSL.com:SSL Corporation: -> data/ca_157.der
|
||||
SwissSign AG:SwissSign AG: -> data/ca_158.der
|
||||
SwissSign AG:SwissSign AG: -> data/ca_159.der
|
||||
SwissSign AG:SwissSign AG: -> data/ca_160.der
|
||||
Taiwan-CA Inc. (TWCA):TAIWAN-CA:Root CA -> data/ca_161.der
|
||||
Taiwan-CA Inc. (TWCA):TAIWAN-CA:Root CA -> data/ca_162.der
|
||||
Telia Company:Telia Finland Oyj: -> data/ca_163.der
|
||||
Telia Company:TeliaSonera: -> data/ca_164.der
|
||||
TrustCor Systems:TrustCor Systems S. de R.L.:TrustCor Certificate Authority -> data/ca_165.der
|
||||
TrustCor Systems:TrustCor Systems S. de R.L.:TrustCor Certificate Authority -> data/ca_166.der
|
||||
ar: creating data/certs.ar
|
||||
|
||||
C:\ZinggJ\ESP8266\BearSSL_CertStore>
|
||||
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This script pulls the list of Mozilla trusted certificate authorities
|
||||
# from the web at the "mozurl" below, parses the file to grab the PEM
|
||||
# for each cert, and then generates DER files in a new ./data directory
|
||||
# Upload these to an on-chip filesystem and use the CertManager to parse
|
||||
# and use them for your outgoing SSL connections.
|
||||
#
|
||||
# Script by Earle F. Philhower, III. Released to the public domain.
|
||||
from __future__ import print_function
|
||||
import csv
|
||||
import os
|
||||
import sys
|
||||
from shutil import which
|
||||
|
||||
from subprocess import Popen, PIPE, call
|
||||
try:
|
||||
from urllib.request import urlopen
|
||||
except Exception:
|
||||
from urllib2 import urlopen
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except Exception:
|
||||
from io import StringIO
|
||||
|
||||
# check if ar and openssl are available
|
||||
if which('ar') is None and not os.path.isfile('./ar') and not os.path.isfile('./ar.exe'):
|
||||
raise Exception("You need the program 'ar' from xtensa-lx106-elf found here: (esp8266-arduino-core)/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed/xtensa-lx106-elf/bin/ar")
|
||||
if which('openssl') is None and not os.path.isfile('./openssl') and not os.path.isfile('./openssl.exe'):
|
||||
raise Exception("You need to have openssl in PATH, installable e.g. from https://download.firedaemon.com/FireDaemon-OpenSSL/FireDaemon-OpenSSL-x64-3.0.7.exe")
|
||||
|
||||
# Mozilla's URL for the CSV file with included PEM certs
|
||||
mozurl = "https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReportPEMCSV"
|
||||
|
||||
# Load the names[] and pems[] array from the URL
|
||||
names = []
|
||||
pems = []
|
||||
response = urlopen(mozurl)
|
||||
csvData = response.read()
|
||||
if sys.version_info[0] > 2:
|
||||
csvData = csvData.decode('utf-8')
|
||||
csvFile = StringIO(csvData)
|
||||
csvReader = csv.reader(csvFile)
|
||||
for row in csvReader:
|
||||
names.append(row[0]+":"+row[1]+":"+row[2])
|
||||
for item in row:
|
||||
if item.startswith("'-----BEGIN CERTIFICATE-----"):
|
||||
pems.append(item)
|
||||
del names[0] # Remove headers
|
||||
del pems[0] # Remove headers
|
||||
|
||||
# Try and make ./data, skip if present
|
||||
try:
|
||||
os.mkdir("data")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
derFiles = []
|
||||
idx = 0
|
||||
# Process the text PEM using openssl into DER files
|
||||
for i in range(0, len(pems)):
|
||||
certName = "data/ca_%03d.der" % (idx);
|
||||
thisPem = pems[i].replace("'", "")
|
||||
print(names[i] + " -> " + certName)
|
||||
ssl = Popen(['openssl','x509','-inform','PEM','-outform','DER','-out', certName], shell = False, stdin = PIPE)
|
||||
pipe = ssl.stdin
|
||||
pipe.write(thisPem.encode('utf-8'))
|
||||
pipe.close()
|
||||
ssl.wait()
|
||||
if os.path.exists(certName):
|
||||
derFiles.append(certName)
|
||||
idx = idx + 1
|
||||
|
||||
if os.path.exists("data/certs.ar"):
|
||||
os.unlink("data/certs.ar");
|
||||
|
||||
arCmd = ['ar', 'q', 'data/certs.ar'] + derFiles;
|
||||
call( arCmd )
|
||||
|
||||
for der in derFiles:
|
||||
os.unlink(der)
|
||||
@@ -0,0 +1,13 @@
|
||||
ECHO OFF
|
||||
REM update_certs.cmd : update certs.ar with actual pems retrieved from mozilla
|
||||
REM
|
||||
REM see also %LOCALAPPDATA%\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\libraries\ESP8266WiFi\examples\BearSSL_CertStore
|
||||
REM
|
||||
REM you may need to install openssl e.g. from https://kb.firedaemon.com/support/solutions/articles/4000121705
|
||||
REM windows installer here: https://download.firedaemon.com/FireDaemon-OpenSSL/FireDaemon-OpenSSL-x64-3.0.7.exe
|
||||
REM
|
||||
SET PATH=%LOCALAPPDATA%\Arduino15\packages\esp8266\tools\python3\3.7.2-post1;%LOCALAPPDATA%\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\bin;%PATH%
|
||||
python3 certs-from-mozilla.py
|
||||
REM
|
||||
REM copy certs.ar manually to parent directory
|
||||
REM
|
||||
Reference in New Issue
Block a user