From 370f217a307abfabd23ac0545ca58b1d7acff351 Mon Sep 17 00:00:00 2001 From: kenkeiras Date: Sun, 27 Oct 2019 21:40:53 +0100 Subject: [PATCH] add example for ssl websocket with CA certificate --- .../WebSocketClientSSLWithCA.ino | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 examples/esp8266/WebSocketClientSSLWithCA/WebSocketClientSSLWithCA.ino diff --git a/examples/esp8266/WebSocketClientSSLWithCA/WebSocketClientSSLWithCA.ino b/examples/esp8266/WebSocketClientSSLWithCA/WebSocketClientSSLWithCA.ino new file mode 100644 index 0000000..6d95d7d --- /dev/null +++ b/examples/esp8266/WebSocketClientSSLWithCA/WebSocketClientSSLWithCA.ino @@ -0,0 +1,111 @@ +/* + * WebSocketClientSSLWithCA.ino + * + * Created on: 27.10.2019 + * + * note SSL is only possible with the ESP8266 + * + */ + +#include + +#include +#include + +#include + +ESP8266WiFiMulti WiFiMulti; +WebSocketsClient webSocket; + +#define USE_SERIAL Serial1 + + +// Can be obtained with: +// openssl s_client -showcerts -connect echo.websocket.org:443 0; t--) { + USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t); + USE_SERIAL.flush(); + delay(1000); + } + + WiFiMulti.addAP("SSID", "passpasspass"); + + while(WiFiMulti.run() != WL_CONNECTED) { + delay(100); + } + + webSocket.beginSslWithCA("echo.websocket.org", 443, "/", ENDPOINT_CA_CERT); + webSocket.onEvent(webSocketEvent); +} + +void loop() { + webSocket.loop(); +}