Check for core version when enabling tls ca cert

Signed-off-by: Frank Meies <19324766+fmeies@users.noreply.github.com>
This commit is contained in:
Frank Meies 2018-12-21 22:49:46 +01:00
parent 435b3afde7
commit d722387344
2 changed files with 81 additions and 77 deletions

View File

@ -248,9 +248,9 @@
// -- MQTT - TLS ----------------------------------
// !!! TLS uses a LOT OF MEMORY so be careful to enable other options at the same time !!!
//#define USE_MQTT_TLS // Use TLS for MQTT connection (+53k code, +15k mem)
//#define USE_MQTT_TLS_ROOTCERT
#define MQTT_TLS_ROOT_CA_LENGTH 846 // Letsencrypt
#define MQTT_TLS_ROOT_CA { \
#define USE_MQTT_TLS_CA_CERT
#define MQTT_TLS_CA_CERT_LENGTH 846 // Letsencrypt
#define MQTT_TLS_CA_CERT { \
0x30, 0x82, 0x03, 0x4a, 0x30, 0x82, 0x02, 0x32, 0xa0, 0x03, 0x02, 0x01, \
0x02, 0x02, 0x10, 0x44, 0xaf, 0xb0, 0x80, 0xd6, 0xa3, 0x27, 0xba, 0x89, \
0x30, 0x39, 0x86, 0x2e, 0xf8, 0x40, 0x6b, 0x30, 0x0d, 0x06, 0x09, 0x2a, \
@ -506,4 +506,8 @@
#error "Select either USE_MQTT_TLS or USE_WEBSERVER as there is just not enough memory to play with"
#endif
#if defined(USE_MQTT_TLS_ROOTCERT) && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
#error "USE_MQTT_TLS_ROOTCERT does not work with core version 2.3.0""
#endif
#endif // _MY_USER_CONFIG_H_

View File

@ -467,9 +467,9 @@ boolean MqttCheckTls(void)
Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter);
AddLog(LOG_LEVEL_DEBUG);
} else {
#ifdef USE_MQTT_TLS_ROOTCERT
unsigned char tls_root_ca[] = MQTT_TLS_ROOT_CA;
if(EspClient.setCACert(tls_root_ca, MQTT_TLS_ROOT_CA_LENGTH)) {
#ifdef USE_MQTT_TLS_CA_CERT
unsigned char tls_ca_cert[] = MQTT_TLS_CA_CERT;
if(EspClient.setCACert(tls_ca_cert, MQTT_TLS_CA_CERT_LENGTH)) {
if (EspClient.verifyCertChain(Settings.mqtt_host)) {
AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_VERIFIED "CA"));
result = true;