diff --git a/libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino b/libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino index f147b361d9..be1ad6e4b7 100644 --- a/libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino +++ b/libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino @@ -1,5 +1,12 @@ // Example of using SSL sessions to speed up SSL connection initiation // +// Note that sessions are a function of individual HTTPS servers, so if you +// are connecting to a service through a load abalncer (i.e. Azure, AWS, GitHub) +// two connections to the same IP address will generally connect to two +// different web servers, meaning that sessions won't work. If you are +// connecting to a single server not behind a load balancer/etc., however, +// there should be a significant speedup. +// // September 2018 by Earle F. Philhower, III // Released to the public domain @@ -94,12 +101,14 @@ void fetchURL(BearSSL::WiFiClientSecure *client, const char *host, const uint16_ void loop() { uint32_t start, finish; BearSSL::WiFiClientSecure client; - BearSSL::X509List cert(cert_DigiCert_High_Assurance_EV_Root_CA); + BearSSL::X509List cert(certForum); + const char *host = "esp8266.com"; + const int port = 443; Serial.printf("Connecting without sessions..."); start = millis(); client.setTrustAnchors(&cert); - fetchURL(&client, github_host, github_port, path); + fetchURL(&client, host, port, path); finish = millis(); Serial.printf("Total time: %dms\n", finish - start); @@ -108,21 +117,21 @@ void loop() { Serial.printf("Connecting with an uninitialized session..."); start = millis(); client.setTrustAnchors(&cert); - fetchURL(&client, github_host, github_port, path); + fetchURL(&client, host, port, path); finish = millis(); Serial.printf("Total time: %dms\n", finish - start); Serial.printf("Connecting with the just initialized session..."); start = millis(); client.setTrustAnchors(&cert); - fetchURL(&client, github_host, github_port, path); + fetchURL(&client, host, port, path); finish = millis(); Serial.printf("Total time: %dms\n", finish - start); Serial.printf("Connecting again with the initialized session..."); start = millis(); client.setTrustAnchors(&cert); - fetchURL(&client, github_host, github_port, path); + fetchURL(&client, host, port, path); finish = millis(); Serial.printf("Total time: %dms\n", finish - start); diff --git a/libraries/ESP8266WiFi/examples/BearSSL_Sessions/certUpdate b/libraries/ESP8266WiFi/examples/BearSSL_Sessions/certUpdate deleted file mode 100755 index ba08b87c32..0000000000 --- a/libraries/ESP8266WiFi/examples/BearSSL_Sessions/certUpdate +++ /dev/null @@ -1,2 +0,0 @@ -cd ${0%/*} 2>/dev/null -python3 ../../../../tools/cert.py -s api.github.com -n github > certs.h diff --git a/libraries/ESP8266WiFi/examples/BearSSL_Sessions/certs.h b/libraries/ESP8266WiFi/examples/BearSSL_Sessions/certs.h index 04765d956c..2d21efdf3a 100644 --- a/libraries/ESP8266WiFi/examples/BearSSL_Sessions/certs.h +++ b/libraries/ESP8266WiFi/examples/BearSSL_Sessions/certs.h @@ -1,90 +1,34 @@ - -// this file is autogenerated - any modification will be overwritten -// unused symbols will not be linked in the final binary -// generated on 2021-07-26 22:04:48 -// by ['../../../../tools/cert.py', '-s', 'api.github.com', '-n', 'github'] - -#pragma once - -//////////////////////////////////////////////////////////// -// certificate chain for api.github.com:443 - -const char* github_host = "api.github.com"; -const uint16_t github_port = 443; - -// CN: *.github.com => name: __github_com -// not valid before: 2021-03-25 00:00:00 -// not valid after: 2022-03-30 23:59:59 -const char fingerprint___github_com [] PROGMEM = "96:84:07:df:0b:1c:f6:58:14:df:d7:33:35:57:51:9b:15:4d:8c:e7"; -const char pubkey___github_com [] PROGMEM = R"PUBKEY( ------BEGIN PUBLIC KEY----- -MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAElL9/+0TidTIALPfU/tiS6pI8zAIk -rU4pohUldVc0bb6O3FARl3cnqIDK9SoF65z3xiR6XsnFS8F0Oy/chXR/kQ== ------END PUBLIC KEY----- -)PUBKEY"; - -// http://cacerts.digicert.com/DigiCertHighAssuranceTLSHybridECCSHA2562020CA1.crt -// CN: DigiCert High Assurance TLS Hybrid ECC SHA256 2020 CA1 => name: DigiCert_High_Assurance_TLS_Hybrid_ECC_SHA256_2020_CA1 -// not valid before: 2020-12-17 00:00:00 -// not valid after: 2030-12-16 23:59:59 -const char cert_DigiCert_High_Assurance_TLS_Hybrid_ECC_SHA256_2020_CA1 [] PROGMEM = R"CERT( +const char certForum [] PROGMEM = R"EOF( -----BEGIN CERTIFICATE----- -MIIEGzCCAwOgAwIBAgIQBmcDW7sU/WOvwNaoU07+FjANBgkqhkiG9w0BAQsFADBs -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j -ZSBFViBSb290IENBMB4XDTIwMTIxNzAwMDAwMFoXDTMwMTIxNjIzNTk1OVowZzEL -MAkGA1UEBhMCVVMxFzAVBgNVBAoTDkRpZ2lDZXJ0LCBJbmMuMT8wPQYDVQQDEzZE -aWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBUTFMgSHlicmlkIEVDQyBTSEEyNTYgMjAy -MCBDQTEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARnvW/xPOudvtC252wTq9ef -6fbdFeWPkOscfpRTkciuHj7UcumQSH3lzkPEIx0KpesWa8epsks7QwkZ4fU/Tkf9 -o4IBhzCCAYMwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQUUGGmoNI1xBEq -II0fD6xC8M0pz0swHwYDVR0jBBgwFoAUsT7DaQP4v0cB1JgmGggC72NkK8MwDgYD -VR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjB/Bggr -BgEFBQcBAQRzMHEwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNv -bTBJBggrBgEFBQcwAoY9aHR0cDovL2NhY2VydHMuZGlnaWNlcnQuY29tL0RpZ2lD -ZXJ0SGlnaEFzc3VyYW5jZUVWUm9vdENBLmNydDBLBgNVHR8ERDBCMECgPqA8hjpo -dHRwOi8vY3JsMy5kaWdpY2VydC5jb20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f+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq +4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA +mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d +emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc= -----END CERTIFICATE----- -)CERT"; - -// http://cacerts.digicert.com/DigiCertHighAssuranceEVRootCA.crt -// CN: DigiCert High Assurance EV Root CA => name: DigiCert_High_Assurance_EV_Root_CA -// not valid before: 2006-11-10 00:00:00 -// not valid after: 2031-11-10 00:00:00 -const char cert_DigiCert_High_Assurance_EV_Root_CA [] PROGMEM = R"CERT( ------BEGIN CERTIFICATE----- -MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs -MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 -d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j -ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL -MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3 -LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug -RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm -+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW -PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM -xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB -Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3 -hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg -EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF -MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA -FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec -nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z -eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF -hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2 -Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe -vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep -+OkuE6N36B9K ------END CERTIFICATE----- -)CERT"; - - -// end of certificate chain for api.github.com:443 -//////////////////////////////////////////////////////////// +)EOF";