diff --git a/custom_config.ini.example b/custom_config.ini.example index 6acc3d03..49baa4b3 100644 --- a/custom_config.ini.example +++ b/custom_config.ini.example @@ -36,3 +36,7 @@ ; Verbose ;build_flags = -DCORE_DEBUG_LEVEL=5 + +;;;; Enable insecure (HTTP) networking ;;;; + +;build_flags = -DHTTP_INSECURE diff --git a/src/uploader.cpp b/src/uploader.cpp index b6e67910..6a926c21 100644 --- a/src/uploader.cpp +++ b/src/uploader.cpp @@ -27,6 +27,7 @@ static char const *const HTTP_LOCATION_HEADER = "location"; // Telekom rootCA certificate +#ifndef HTTP_INSECURE static const char *const rootCACertificate = "-----BEGIN CERTIFICATE-----\n" "MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx\n" @@ -51,12 +52,16 @@ static const char *const rootCACertificate = "9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP\n" "BSeOE6Fuwg==\n" "-----END CERTIFICATE-----\n"; +#endif Uploader::Uploader(String portalUrl, String userToken) : mPortalUrl(std::move(portalUrl)), mPortalUserToken(std::move(userToken)) { ObsUtils::setClockByNtpAndWait(); + +#ifndef HTTP_INSECURE mWiFiClient.setCACert(rootCACertificate); +#endif } /* Upload file as track data to "The Portal" as multipart form data. diff --git a/src/uploader.h b/src/uploader.h index d6cc0ae9..b6fd3fc0 100644 --- a/src/uploader.h +++ b/src/uploader.h @@ -2,7 +2,11 @@ #define UPLOADER_H #include +#ifdef HTTP_INSECURE +#include +#else #include +#endif #include class Uploader { @@ -18,7 +22,11 @@ class Uploader { private: const String mPortalUrl; const String mPortalUserToken; +#ifdef HTTP_INSECURE + WiFiClient mWiFiClient; +#else WiFiClientSecure mWiFiClient; +#endif String mLastLocation = ""; String mLastStatusMessage = "NO UPLOAD";