Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
b85496aa
Commit
b85496aa
authored
Feb 25, 2022
by
Eric Duminil
Browse files
Broken https
parent
3a9ec97d
Pipeline
#5954
failed with stage
in 2 minutes and 2 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/wifi_util.cpp
View file @
b85496aa
...
...
@@ -7,13 +7,52 @@
#include "sensor_console.h"
#if defined(ESP8266)
# include <ESP8266WiFi.h>
# include <ESP8266HTTPClient.h>
# include <ESP8266httpUpdate.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include <WiFiClientSecure.h>
#include <CertStoreBearSSL.h>
BearSSL
::
CertStore
certStore
;
#include <time.h>
#elif defined(ESP32)
# include <WiFi.h>
#endif
const
char
*
host
=
"transfer.hft-stuttgart.de"
;
const
int
httpsPort
=
443
;
// DigiCert High Assurance EV Root CA
const
char
trustRoot
[]
PROGMEM
=
R"EOF(
-----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-----
)EOF"
;
X509List
cert
(
trustRoot
);
extern
const
unsigned
char
caCert
[]
PROGMEM
;
extern
const
unsigned
int
caCertLen
;
namespace
wifi
{
char
local_ip
[
16
];
// "255.255.255.255\0"
...
...
@@ -38,9 +77,17 @@ namespace wifi {
ESPhttpUpdate
.
onEnd
(
update_finished
);
ESPhttpUpdate
.
onProgress
(
update_progress
);
ESPhttpUpdate
.
onError
(
update_error
);
WiFiClient
client
;
t_httpUpdate_return
ret
=
ESPhttpUpdate
.
update
(
client
,
"http://servfbp1.fbp.hft-stuttgart.de/simstadt_doc/firmware.bin"
);
//TODO: Update https link to latest build
WiFiClientSecure
client
;
client
.
setTrustAnchors
(
&
cert
);
if
(
!
client
.
connect
(
host
,
httpsPort
))
{
Serial
.
println
(
"Connection failed"
);
return
;
}
client
.
setInsecure
();
t_httpUpdate_return
ret
=
ESPhttpUpdate
.
update
(
client
,
"https://transfer.hft-stuttgart.de/gitlab/co2ampel/ampel-firmware/-/jobs/13470/artifacts/raw/.pio/build/esp8266/firmware.bin"
);
// Or:
//t_httpUpdate_return ret = ESPhttpUpdate.update(client, "server", 80, "file.bin");
//TODO: https://github.com/programmer131/ESP8266_ESP32_SelfUpdate
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment