知的好奇心 for IoT

IoT関連の知的好奇心を探求するブログです

Arduino core for the ESP32 1.0.5でWiFiClinetSecureの使い方が変更されて、HTTPS(TLS)接続前に証明書の検証方法の明示が必要になっていた

Arduino core for the ESP32 1.0.4までは、HTTPS(TLS)接続は単に次のコードを実行すれば繋ぐことができました。

WiFiClientSecure client;
client.connect("www.howsmyssl.com", 443);

しかし、Arduno core for the ESP32 1.0.5では、上記の接続コード実行前にサーバー証明書の検証方法の明示が必須となり、明示せずに接続すると単に接続に失敗するだけではなく、場合によってはESP32がリスタートするという現象が発生します。

Arduino core for the ESP32 1.0.5のWiFiClinetSecureクラスにはsetInsecureメンバが追加されていて、サーバー証明書の検証をせずに接続する場合はsetInsecureの明示が必須になっています。

WiFiClientSecure client;
client.setInsecure();
client.connect("www.howsmyssl.com", 443);

 

スケッチ例に収録されているWiFiClientSecureのサンプルコードもArduino core for the ESP32 1.0.4までは次の3つです。

  • WiFiClientPSK
  • WiFiClientSecure
  • WiFiClientSecureEnterprise

Arduino core for the ESP32 1.0.5では上記3つのサンプルコードに以下のサンプルコードが追加されています。

  • WiFiClientInsecure