{"id":121186,"date":"2022-12-09T15:51:35","date_gmt":"2022-12-09T15:51:35","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=121186"},"modified":"2022-12-09T15:51:36","modified_gmt":"2022-12-09T15:51:36","slug":"esp32-esp8266-https-ssl-tls","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-esp8266-https-ssl-tls\/","title":{"rendered":"ESP32\/ESP8266 with HTTPS and SSL\/TLS Encryption: Basic Concepts"},"content":{"rendered":"\n<p>This article is a quick and simple introduction to HTTPS and SSL\/TLS encryption with the ESP32 and ESP8266 NodeMCU board. We&#8217;ll take a look at some concepts and terms that you&#8217;ve probably heard before but you might not know exactly what they mean: HTTPS, SSL\/TLS, certificates, asymmetric and symmetric key encryption, and more.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-ESP8266-HTTPS-Basic-Concepts.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ESP8266 NodeMCU HTTPS and SSL TLS Encryption Basic Concepts\" class=\"wp-image-121361\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-ESP8266-HTTPS-Basic-Concepts.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-ESP8266-HTTPS-Basic-Concepts.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-ESP8266-HTTPS-Basic-Concepts.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-ESP8266-HTTPS-Basic-Concepts.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p><strong>Table of Contents<\/strong><\/p>\n\n\n\n<p>Throughout this article, we&#8217;ll cover the following subjects:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"#what-is-https\">What is HTTPS?<\/a><ul><li><a href=\"#why-https\">Why do you need HTTPS?<\/a><\/li><\/ul><\/li><li><a href=\"#SSL-TLS\">What is SSL\/TLS?<\/a><\/li><li><a href=\"#SSL-TLS-how-it-works\">How does SSL\/TLS encryption work?<\/a><ul><li><a href=\"#public-key-private-key\">Public key and private key<\/a><\/li><\/ul><\/li><li><a href=\"#https-communication\">Communication over HTTPS<\/a><\/li><li><a href=\"#ssl-certificates\">SSL certificates<\/a><\/li><li><a href=\"#self-signed-certificates\">Self-signed certificates<\/a><\/li><li><a href=\"#esp32-https-requests\">ESP32: HTTPS requests (Arduino IDE)<\/a><\/li><li><a href=\"#esp32-https-server\" target=\"_blank\" rel=\"noopener\">ESP32 HTTPS server (Arduino IDE)<\/a><\/li><li><a href=\"#esp8266-https-requests\">ESP8266: HTTPS requests (Arduino IDE)<\/a><\/li><li><a href=\"#esp8266-https-server\">ESP8266 HTTPS server (Arduino IDE)<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-https\">What is HTTPS?&nbsp;<\/h2>\n\n\n\n<p>HTTPS is the secure version of the HTTP protocol, hence the \u201cS\u201d, which stands for secure.<\/p>\n\n\n\n<p>HTTP is a protocol to transfer data over the internet. When that data is encrypted with SSL\/TLS, it\u2019s called HTTPS.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"500\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTP-vs-HTTPS.png?resize=750%2C500&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"HTTP vs HTTPS requests protocol\" class=\"wp-image-121260\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTP-vs-HTTPS.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTP-vs-HTTPS.png?resize=300%2C200&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>To simplify, HTTPS is just the HTTP protocol but with encrypted data using SSL\/TLS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"why-https\">Why do you need HTTPS?<\/h3>\n\n\n\n<p>Using HTTPS ensures the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Privacy<\/strong>: no one can spy on your requests and passwords because the messages are encrypted.<\/li><li><strong>Integrity<\/strong>: the message is not manipulated on its way to its destination (prevents men-in-the-middle) attacks.<\/li><li><strong>Identification:<\/strong> when using HTTPS, via SSL certificates, you ensure you are connected to the server you would expect.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"SSL-TLS\">What is SSL\/TLS?<\/h2>\n\n\n\n<p><strong>SSL <\/strong>stands for <strong>S<\/strong>ecure <strong>S<\/strong>ocket <strong>L<\/strong>ayer and <strong>TLS<\/strong> stands for <strong>T<\/strong>ransport <strong>L<\/strong>ayer <strong>S<\/strong>ecurity. These are two protocols used for secured encryption. SSL is currently deprecated. TLS 1.3 is currently the most recent protocol used for secure encryption on the web.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"SSL-TLS-how-it-works\">How does SSL\/TLS encryption work?<\/h2>\n\n\n\n<p>There are two types of encryption algorithms: <strong>symmetric key algorithm<\/strong> and <strong>asymmetric key algorithm<\/strong>.<\/p>\n\n\n\n<p><strong>Symmetric Key Encryption<\/strong><\/p>\n\n\n\n<p>With a symmetric-key algorithm, the same key is used to encrypt and decrypt the messages. So, both the client and server need to have the same key.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"445\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/Symmetric-key-encryption.png?resize=750%2C445&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Symmetric key encryption How does SSL TLS encryption work\" class=\"wp-image-121261\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/Symmetric-key-encryption.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/Symmetric-key-encryption.png?resize=300%2C178&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The disadvantage of using a symmetric key algorithm is that keys are hard to share and you need to be careful how and with who you distribute the key.<\/p>\n\n\n\n<p><strong>Asymmetric Key Encryption<\/strong><\/p>\n\n\n\n<p>The SSL\/TLS encryption uses asymmetric keys.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"465\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/Asymmetric-key-encryption.png?resize=750%2C465&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Asymmetric Key Encryption SSL TLS encryption\" class=\"wp-image-121262\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/Asymmetric-key-encryption.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/Asymmetric-key-encryption.png?resize=300%2C186&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>How does asymmetric key encryption work? Very briefly:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>You have two asymmetric keys: a public key and a private key.<\/li><li>The public key and private key work together.<\/li><li>The public key, as the name suggests, is visible to anyone.<\/li><li>Only the private key can decrypt the message encrypted with the corresponding public key.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"public-key-private-key\">Public Key and Private Key<\/h3>\n\n\n\n<p>In summary, here\u2019s how it works:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The browser client tries to contact the server.<\/li><li>The server sends the public key to the client (browser) via the server&#8217;s SSL certificate.<\/li><li>The browser sends a message to the server encrypted with the public key.<\/li><li>Only the ones with the private key (the server) can decipher the message.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"https-communication\">Communication over HTTPS<\/h2>\n\n\n\n<p>How the communication between the server and client works over HTTPS? The following diagram shows a high-level overview of how it works.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"947\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTPS-Communication-SSL-certificte_f.png?resize=750%2C947&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"HTTPS communication with SSL certificate\" class=\"wp-image-121264\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTPS-Communication-SSL-certificte_f.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTPS-Communication-SSL-certificte_f.png?resize=238%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 238w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\"><li>You, the client on your browser, try to connect with the server (<strong>1<\/strong>);<\/li><li>The server sends back its certificate (<strong>2<\/strong>) so that the browser can check the authenticity of the server (<strong>3<\/strong>). The certificate contains the public key.<\/li><li>If the certificate is valid, the client creates a new key (called session key) (<strong>4<\/strong>) that will be used later to encrypt communication between the client and server. <\/li><li>The client encrypts the session key using the public key sent by the server (<strong>5<\/strong>).<\/li><li>The server receives the session key encrypted with the public key and can decipher the message because only the server has access to the corresponding private key to decrypt the message (<strong>6<\/strong>);<\/li><li>From now on, both the client and server have a secret key (that&#8217;s only known to them) that they can use to encrypt further communication (<strong>7<\/strong>) (symmetric key encryption).<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ssl-certificates\">SSL Certificates<\/h2>\n\n\n\n<p>SSL certificates are issued by legitimate Certificate Authorities. One of the most known is LetsEncrypt. Certificate Authorities also confirm the identity of the certificate owner and provide proof that the certificate is valid.&nbsp;<\/p>\n\n\n\n<p>When a Certificate Authority issues a certificate, it signs the certificate with its root certificate. This root certificate should be on the database of trusted certificates.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"468\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTPS-browser-valid-certificate.png?resize=750%2C468&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"SSL Certificates Client Server interaction\" class=\"wp-image-121269\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTPS-browser-valid-certificate.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/HTTPS-browser-valid-certificate.png?resize=300%2C187&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Your browser then checks if the certificate is valid (if it was signed with a root certificate on the database of trusted root certificates) and displays a green lock icon on the browser bar if it is.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"self-signed-certificates\"><strong>Self-signed Certificates<\/strong><\/h3>\n\n\n\n<p>You can self-sign your certificates. These provide the same level of encryption as one generated by an authority, and these are free. However, all browsers will check if the certificate is issued by a trusted Certificate Authority. So, you\u2019ll be warned by your browser that the site you\u2019re visiting is not safe because it doesn\u2019t trust the certificate and so, can\u2019t identify its owner.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"468\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/browser-self-signed-certificate_HTTPS-browser-self-signedcate.png?resize=750%2C468&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Self-signed certificates web browser\" class=\"wp-image-121271\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/browser-self-signed-certificate_HTTPS-browser-self-signedcate.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/browser-self-signed-certificate_HTTPS-browser-self-signedcate.png?resize=300%2C187&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The web browser will display a warning sign and the HTTPS letters in red. This means the website has a certificate, but the certificate is unverified (like self-signed certificates) or out of date. This means that the connection between you and the server is encrypted, but no one can guarantee that the domain really belongs to the company indicated on the site.&nbsp;<\/p>\n\n\n\n<p>Self-signed certificates are fine to use on your DIY and IoT projects, intranets, like your local network, or inside a company\u2019s network. However, if you\u2019re creating a project for a company that will be accessed by clients outside the company network, like a public website, it\u2019s best to use a certificate from a Certificate Authority.<\/p>\n\n\n\n<p>SSL certificates have an expiry date. So, if you\u2019re using an ESP32 to connect to a website via HTTPS, you should keep in mind that you\u2019ll need to update the code with the new website\u2019s certificate in the future.<\/p>\n\n\n\n<p>If you\u2019re still confused about all of these new terms, we recommend taking a look at the following website that explains in a fun way how everything works: https:\/\/howhttps.works\/.  <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esp32-https-requests\">ESP32: HTTPS Requests (Arduino IDE)<\/h2>\n\n\n\n<p>If you\u2019re familiar with HTTP requests with the ESP32 \u201cmigrating\u201d to HTTPS is very straightforward. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"320\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-HTTPS-Requests.png?resize=750%2C320&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 HTTPS Requests Arduino IDE secure connection client server SSL certificate\" class=\"wp-image-121362\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-HTTPS-Requests.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-HTTPS-Requests.png?resize=300%2C128&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>If you&#8217;re using the <span class=\"rnthl rntliteral\">WiFiClient<\/span> library, you just need to make the following changes:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Use <span class=\"rnthl rntliteral\">WiFiClientSecure.h<\/span> library instead of <span class=\"rnthl rntliteral\">WiFiClient.h<\/span><\/li><li>Use port <span class=\"rnthl rntliteral\">443<\/span> instead of port <span class=\"rnthl rntliteral\">80<\/span><\/li><li>Change the host URL to <span class=\"rnthl rntliteral\">https<\/span> instead of <span class=\"rnthl rntliteral\">http<\/span><\/li><\/ol>\n\n\n\n<p>With this, you ensure that your communication is encrypted using TLS.<\/p>\n\n\n\n<p>An additional security step is to check the server certificate (the certificate of the website you want to connect to). You can skip this step while testing and prototyping. The communication will be encrypted, but you won\u2019t be sure of the integrity of the server you are trying to communicate with.<\/p>\n\n\n\n<p>You can also find examples using HTTPS with the <span class=\"rnthl rntliteral\">HTTPClient<\/span> library.<\/p>\n\n\n\n<p>If you want to start working on your HTTPS requests right away, take a look at the examples provided in the ESP32 package for the Arduino core.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>WiFiClientSecure example: <strong>File <\/strong>&gt; <strong>Examples <\/strong>&gt; <strong>ESP32 <\/strong>&gt; <strong>WFiClientSecure <\/strong>&gt; <strong><a href=\"https:\/\/github.com\/espressif\/arduino-esp32\/blob\/master\/libraries\/WiFiClientSecure\/examples\/WiFiClientSecure\/WiFiClientSecure.ino\" target=\"_blank\" rel=\"noopener\">WiFiClientSecure<\/a><\/strong><\/li><li>HTTPClient with HTTPS example: <strong>File <\/strong>&gt; <strong>Examples <\/strong>&gt; <strong>ESP32 <\/strong>&gt; <strong>BasicHttpsClient <\/strong>&gt; <strong><a href=\"https:\/\/github.com\/espressif\/arduino-esp32\/blob\/master\/libraries\/HTTPClient\/examples\/BasicHttpsClient\/BasicHttpsClient.ino\" target=\"_blank\" rel=\"noopener\">BasicHttpsClient<\/a><\/strong><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esp32-https-server\">ESP32 HTTPS Server (Arduino IDE)<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"243\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-HTTPS-Server.png?resize=750%2C243&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 HTTPS Requests Arduino IDE secure connection client server SSL certificate\" class=\"wp-image-121364\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-HTTPS-Server.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-HTTPS-Server.png?resize=300%2C97&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>At the moment, there are not many examples of building an HTTPS web server with the ESP32 using the Arduino core. Unfortunately, the <span class=\"rnthl rntliteral\">AsyncWebServer<\/span> library that we use in most of our projects, doesn\u2019t fully support HTTPS at the moment.<\/p>\n\n\n\n<p>Nevertheless, there is another library that provides easy methods to build an ESP32 HTTPS web server, including an example that generates certificates on the fly. Here\u2019s a link to the library: <a href=\"https:\/\/github.com\/fhessel\/esp32_https_server\" target=\"_blank\" rel=\"noopener\">esp32_https_server library<\/a>.<\/p>\n\n\n\n<p>If you\u2019re familiar with ESP-IDF, you can take a look at the documentation on the following link:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/docs.espressif.com\/projects\/esp-idf\/en\/latest\/esp32\/api-reference\/protocols\/esp_https_server.html\" target=\"_blank\" rel=\"noopener\">ESP-IDF HTTPS Server Documentation<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esp8266-https-requests\">ESP8266 HTTPS Requests (Arduino IDE)<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"320\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP8266-HTTPS-Requests.png?resize=750%2C320&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 NodeMCU HTTPS Requests Arduino IDE secure connection client server SSL certificate\" class=\"wp-image-121365\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP8266-HTTPS-Requests.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP8266-HTTPS-Requests.png?resize=300%2C128&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>There are several examples that show how to make HTTPS requests with the ESP8266. You can check the examples available in your Arduino IDE. Make sure you have the latest version of the ESP8266 boards installed to make sure you have access to the latest version of the examples and that these will work.<\/p>\n\n\n\n<p>To update the ESP8266 boards&#8217; installation, you just need to go to <strong>Tools <\/strong>&gt; <strong>Boards <\/strong>&gt; <strong>Boards Manager<\/strong>, search for <strong>ESP8266, <\/strong>and install the latest version.<\/p>\n\n\n\n<p>Then, you&#8217;ll have access to the examples&#8217; latest version. You can check the following examples:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Basic HTTPS Client using the <span class=\"rnthl rntliteral\">ESP8266HTTPClient<\/span> library: <strong>File <\/strong>&gt; <strong>Examples<\/strong> &gt; <strong>ESP8266HTTPClient <\/strong>&gt; <strong><a href=\"https:\/\/github.com\/esp8266\/Arduino\/blob\/master\/libraries\/ESP8266HTTPClient\/examples\/BasicHttpsClient\/BasicHttpsClient.ino\" target=\"_blank\" rel=\"noopener\">BasicHttpsClient<\/a><\/strong><\/li><li>Basic HTTPS Client using <span class=\"rnthl rntliteral\">WiFiClientSecure<\/span> library: <strong>File <\/strong>&gt; <strong>Examples <\/strong>&gt; <strong>ESP8266WiFi <\/strong>&gt; <strong><a href=\"https:\/\/github.com\/esp8266\/Arduino\/tree\/master\/libraries\/ESP8266WiFi\/examples\/HTTPSRequest\" target=\"_blank\" rel=\"noopener\">HTTPSRequest<\/a><\/strong><\/li><\/ul>\n\n\n\n<p>You&#8217;ll need to update the certificates and fingerprints to make the examples work. If you can&#8217;t make the examples work, don&#8217;t worry, we&#8217;ll publish some tutorials with examples and instructions soon.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"esp8266-https-server\">ESP8266 HTTPS Server (Arduino IDE)<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"243\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP8266-HTTPS-Server.png?resize=750%2C243&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 NodeMCU Server HTTPS Requests Arduino IDE secure connection client server SSL certificate\" class=\"wp-image-121363\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP8266-HTTPS-Server.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP8266-HTTPS-Server.png?resize=300%2C97&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The ESP8266 is not optimized for SSL cryptography, so running an HTTPS Server on the ESP8266 is very demanding. You need to set the clock frequency to 160MHz and even so, you might get unexpected resets on the board. <\/p>\n\n\n\n<p>For an ESP8266 HTTPS web server, you can take a look at an example using the <span class=\"rnthl rntliteral\">ESP8266WebServer<\/span> library on the following link:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/esp8266\/Arduino\/blob\/master\/libraries\/ESP8266WebServer\/examples\/HelloServerBearSSL\/HelloServerBearSSL.ino\" target=\"_blank\" rel=\"noopener\">ESP8266 HTTPS Server (BearSSL)<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, we\u2019ve taken a look at the HTTPS protocol, SSL\/TLS encryption, and SSL certificates. I\u2019m far from being an expert in these subjects, so if anything doesn\u2019t sound right in this article, please let me know in the comments below.<\/p>\n\n\n\n<p>We\u2019ve also taken a quick look at possible ways to secure your ESP32\/ESP8266 IoT projects: how to make HTTPS requests and how to set the ESP32\/ESP8266 as an HTTPS server with a certificate. We\u2019ll create more tutorials with practical examples about these subjects in the upcoming weeks, so stay tuned.<\/p>\n\n\n\n<p>If you have any examples of HTTPS servers with the ESP32 or are familiar with any other libraries to build an HTTPS server, please share them in the comments below.<\/p>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article is a quick and simple introduction to HTTPS and SSL\/TLS encryption with the ESP32 and ESP8266 NodeMCU board. We&#8217;ll take a look at some concepts and terms that &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32\/ESP8266 with HTTPS and SSL\/TLS Encryption: Basic Concepts\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-esp8266-https-ssl-tls\/#more-121186\" aria-label=\"Read more about ESP32\/ESP8266 with HTTPS and SSL\/TLS Encryption: Basic Concepts\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":121361,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,277,299,264],"tags":[],"class_list":["post-121186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/11\/ESP32-ESP8266-HTTPS-Basic-Concepts.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/121186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=121186"}],"version-history":[{"count":18,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/121186\/revisions"}],"predecessor-version":[{"id":123121,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/121186\/revisions\/123121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/121361"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=121186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=121186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=121186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}