#232

Sdílet
Vložit
  • čas přidán 12. 10. 2018
  • Most of our IOT devices are insecure and vulnerable. It’s high time to learn how to make them more secure, also because unsecured devices will no more be able to use valuable services without using the HTTPS protocol. Already now, Google services, for example, do no more accept unsecured connections. But is it complicated? Let’s find out!
    Our ESP8266 and ESP32s support such secure connections. In this video, I will show you, how to change your unsecured sketches it in a few simple steps. And you will learn some basics about encryption and certificates. Which you can use during the next discussion with your boss or your colleagues.
    We will cover:
    1. How does SSL work? We just need the most basic knowledge
    2. How can we access cloud services using HTTPS with our ESP8266 and ESP32?
    3. How can we create trust?
    4. How much memory is needed on our devices?
    Links:
    Sketches: github.com/Sen...
    Supporting Material and Blog Page: www.sensorsiot.org
    Github: www.github.com...
    My Patreon Page: / andreasspiess
    My Bitcoin address: 19FSmqbBzb5zsYB1d8Bq4KbxVmezToDNTV
    If you want to support the channel, please use the links below to start your shopping. No additional charges for you, but I get a commission (of your purchases the next 24 hours) to buy new stuff for the channel
    For Banggood bit.ly/2jAQEf4
    For AliExpress: bit.ly/2B0yTLL
    For ebay.com: ebay.to/2DuYXBp
    www.facebook.c...
    / spiessa
    www.instructab...
    Please do not try to Email me or invite me on LinkedIn. These communication channels are reserved for my primary job
    Equipment in my lab: www.sensorsiot....
  • Věda a technologie

Komentáře • 381

  • @zvpunry1971
    @zvpunry1971 Před 5 lety +88

    Comparing the CAs to the Mafia was absolutely great! :)

  • @alejandrov9500
    @alejandrov9500 Před 3 lety +3

    One or two years ago I saw a series of your videos that I really liked. These days I spend hours learning from your videos. The explanations are among the best I have heard in my entire life, the format and presentation are excellent. You are a very good communicator, the speech is clear, precise and summarized. I also like your humor and comments, it makes the content lighter. Sincerely grateful for sharing your knowledge in this way and working so hard to make these super lessons.

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      Thank you for your nice words! Glad my videos are helpful.

  • @c2h7
    @c2h7 Před 4 lety +14

    Even though I already know most of the SSL details and almost skipped forward, I'm glad I didn't because you explain things very nicely. So well that even after reading about HTTPS from 3-5 different sources, it finally clicks when you explain it. You should teach professionally :-)

    • @AndreasSpiess
      @AndreasSpiess  Před 4 lety +7

      Thank you. I teach sometimes at Universities. But here I have a bigger audience ;-)

  • @sethrd999
    @sethrd999 Před 5 lety +3

    This is a great intro into SSL for anyone new to the subject, I do alot of conversions myself as I use ( mostly dreaded ) KeyStore/TrustStore in Java and have to provide the chains as you describe in the browser. I would just add that anyone venturing into this territory ( even under windows ) to familiarize yourself with the openssl command and its syntax, just be aware that I have found some quirks with windows that the only work around I found was to move all the required files to a linux system ( VM ) and finish up there.
    I to use letsencrypt using the certbot engine to roll my keys when they expire automatically ( In my home ), super slick and easy to get up and going once you understand the basic principles.
    Great video as always.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Thank you! I think your comment is more for the server side. In this video, I tried to focus on the client/IOT side to be able to access HTTPS servers. So far I never built a server myself (other than my Raspberries behind my firewall).

  • @altosack
    @altosack Před 3 lety

    Fantastic!
    I had used public/private key encryption for years, both as a user and a programmer, without really understanding how it works; I only thought I did. You explained it simply, and in a way I will never forget, before minute five in this video.
    Bravo, sir!

  • @northshorepx
    @northshorepx Před 5 lety +3

    This is something at everyone should be thinking about before any communications take place!

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +5

      I hope I am able to remove some of the fear many people have to start with this technology.

    • @northshorepx
      @northshorepx Před 5 lety +1

      yes Andreas -your down to earth tutorials really do help!

    • @andybarnard4575
      @andybarnard4575 Před 5 lety +1

      I agree we should think about data security. Having done so I use two alternative approaches to securing traffic with esp8266. Firstly put http traffic from esp8266 through a VPN tunnel if endpoints are controlled, secondly use SSL reverse proxy server. A raspberry pi or similar can perform both functions.

    • @slinco65
      @slinco65 Před 5 lety +1

      @@andybarnard4575 would you explain to us how you do that please?

    • @andybarnard4575
      @andybarnard4575 Před 5 lety

      At a high level, yes, for detail I always use Google... I use esp8266s mostly as servers, not clients, and I use orange pi on armbian for the SSL part. For reverse proxy 1. install apache on a suitable server (apt-get install apache2 or similar...) 2. get a dynamic dns name (eg. from afraid.org, use their updating script) 3. get a lets encrypt cert from certbot.org use full automatic method 3. configure local router to always give ESP8266 server same LAN IP address 4. install apache_mod proxy and configure using the 'digitial ocean' guide (google reverse proxy and digital ocean). 5. Access esp8266 securely over internet. 6. In VPN scenario you have two sites both with dynamic DNS e.g. as step 2 and a box at each end 7. Install VPN server on one site, VPN client on another. 8. Many solutions for this e.g. open vpn again use digital ocean config guide, but for other reasons I use L2TP with client from a Mikrotik RouterOS running on a HAP lite and configure a server on the main site using Softether VPN. Both have good config guides. On server side need to make sure firewalls and portforwading is configured. Thats how I do it, and just as a for instance. Result is ESP8266 sketches communicating over internet in secure manner but without having to deal with SSL themselves. Hope the concepts at least are of some use to you.

  • @4.0.4
    @4.0.4 Před 5 lety +2

    When I first started reading about the ESP8266 when it came out, one of the first things I thought was "ok, but what about encryption?" and was surprised at how hard it was, and how uncommon. Today's IoT infrastructure is pretty unsafe.
    I think the best model right now is to use SBCs as central hubs to microcontrollers, since even the cheapest $10 SBCs can do HTTPS just fine. Sometimes, even the work of microcontrollers can be done by the SBC, especially when it isn't timing-critical. Plus you can then code logic as scripts rather than C.
    Microcontrollers shine when low-power and real-time processing is required, but the difficulty to make them secure must not be ignored. It's always good to assume that these devices aren't safe and consider the implications. "What could a hacker do with this?" For things like lamp colors, air conditioner automation, motorized blinds, homemade weather stations, etc - then even HTTP is good enough.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      I agree. My problem was more that many companies do no more accept HTTP connections. And I find the combination of ESPs and cloud services a good thing.

  • @velox__
    @velox__ Před 4 lety +2

    I had just about given up on this, but this got me on the right track! Thank you!

  • @asiw
    @asiw Před 5 lety +1

    Excellent. Thank you for making a complex subject accessible. Wouldn't it be nice if we didn't have to do this but unfortunately there are always some people who will try to cheat.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      :-)
      I think cheating was already in the first plans of whoever designed humans...

  • @geralde.5724
    @geralde.5724 Před 5 lety +3

    In the esp8266 versions you have "connect(); verify(); connect(); send()", you can leave the second connect() out. Good to see the esp getting better at tls encryption!(when i researched the cert method wasn't available yet)

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Thanks for the tip. I used the example files and did not bother too much...

  • @tonybell1597
    @tonybell1597 Před 5 lety +1

    Thanks Andreas, perfect, all boiled down to what we need to know.... Feel confident to get it done in my own sketches now....

  • @freeelectron8261
    @freeelectron8261 Před 5 lety

    That "guy with a Swiss accent" sure is smart! Thanks Andreas another great lesson :)

  • @gte24v
    @gte24v Před 5 lety

    Excellent video, thank you. I loved the Mafia parallel, "is he a friend of yours, or is he a friend of *ours*?" as a colleague used to say at work a few years ago. This is something I have been meaning to do for quite some time and your explanation made it even simpler. :-)

  • @PhG1961
    @PhG1961 Před 5 lety +1

    Great video and an excellent tutorial on security which usually doens't get too much attention.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      It is not only about security. If our cloud services change, we will no more be able to use them :-(

  • @sbx320
    @sbx320 Před 5 lety +4

    Some notes:
    - If you are running the server (for example when communicating between an esp32 and your PC) you can also create your own certificate authority and make your client esp32 trust that CA. Usually referred to as "self signed" certificates. Same security, less Mafia :)
    - For validation via fingerprints you can also use the fingerprint of the certificate authority (or any other point in the chain). Not sure if that's easily available with WifiClientSecure (my esp32 is still in the mail)
    - Supporting more cipher suites may actually be bad, as an attacker can remove secure ciphers from that list via a downgrade attack. Therefore you might end up using an insecure cipher.
    If you control the server, other options may actually be better for performance. For example you could avoid the asymmetric crypto part by supplying your device with a static symmetric key once. If you only care about integrity (no one else may edit the data) and not about confidentiality (no one else may see the data) just signing the data is enough.
    Not sure how much of those is exposed in easy to use libraries for the esp32, but since it can do https, both ideas should be fairly easy to achieve.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Thank you for your comment. This video was focussed on accessing available services outside the firewall. So far, I do not encrypt the traffic behind my firewall. I am sure your comment helps if somebody wants to do that.

    • @GRBtutorials
      @GRBtutorials Před 5 lety +1

      This doesn't have anything to do with firewalls. It's about running your own server, something you can do either locally, available only to your LAN unless you configure the NAT and have a static IP address or use a dynamic DNS service such as No-IP (free with limitations); or remotely, with a hosting provider.

  • @SolarWebsite
    @SolarWebsite Před 5 lety +6

    This is extremely informative, thank you very much.

  • @geros9503
    @geros9503 Před 5 lety +1

    Thank you Andreas, great explanation. Loved the Mafia comparison.

  • @UMERLEO
    @UMERLEO Před 5 lety

    thanks alot. i can now explain with confidence if someone asks me instead of blabbering on. Couldnt find any easy explanation/comparison elsewhere.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I also had to search and combine different sources...

  • @BreakingBytes32
    @BreakingBytes32 Před 3 lety

    thanks lot.... my smart home system with telegram bot stopped working few days ago due to this issue.... i didn't found any documents or tutorial to understand this...... but now i think i can make it work again... thanks a lot 🙂

  • @michelebernasconi375
    @michelebernasconi375 Před 5 lety +2

    Great practical tutorial, thanks a lot!

  • @duraffourgmaud6145
    @duraffourgmaud6145 Před 3 lety +2

    Thank you for this tutoriel, it was just the right thing to get me started on my project. Really easy to understand ! Your channel is really a gold mine for IOT users !
    I'm working with an ESP32 and an MQTT Server. I found that the way to make the connection secure with the server is close to what you show in this video, with some nice certificate. It's working quite nicely in local network, and it's in part thanks to you !
    But if my ESP32 is outside the network, then I manage to reach the server (with it's public ip and some port forwarding on my box), but I can't connect to it. Did you ever had a similar problem ? It's quite mysterious : I know my certificate is ok, as is my server. But suddenly the server told me my certificate is corrupt. Almost mystifying, really.

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      A project I was involved (IOTappstory) had to solve this problem. But I do not know the details. I only know it was not easy :-(

    • @duraffourgmaud6145
      @duraffourgmaud6145 Před 3 lety

      @@AndreasSpiess Ah, I can believe it, network problem is never easy. I don't believe you've got an hint on how it was solved ?

  • @MultigrainKevinOs
    @MultigrainKevinOs Před 5 lety

    excellent video! thanks fro pulling all the information together to help explain certs, its always been something i only quasi knew how it functioned but this sure clears it up and i want to update my DIY sketches now to secure them :)

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      The same on this end. So I invested the time to learn it and thought it might be of value for others...

  • @thesimbon
    @thesimbon Před 5 lety

    Thanks again for another useful video and the sketches too.

  • @iangster3216
    @iangster3216 Před 5 lety +1

    I wish I was swiss you have so much freedom there

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +4

      We also have our wives who restrict it considerably ;-)

  • @duncanx99
    @duncanx99 Před 5 lety +3

    Excellent - but I'm going to need to watch it a few times to grasp the methods for implementing HTTPS...

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I also had to watch several videos to understand it. You are not alone ;-)

  • @rodstartube
    @rodstartube Před 5 lety +3

    As always great info and great explanation, however, it would be great to know how much power and data bandwidth SSL consumes over non SSL.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Another viewer shared his experience. I pinned the comment. Maybe you read it. The bandwidth usually is no big issue.

  • @pawel753
    @pawel753 Před 5 lety +4

    Great tutorial as always! However, I think one important step is missing here - how to get a certificate from trusted CA. As I see from your screenshots you're using LetsEncryptIt certificate, do you plan to create another video on this? Thanks!

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      This video did not cover the web server part. Because of that, I did not cover the installation of certificates on the ESP. In this scenario, there was no need for creating certificates as this is done by the service providers.
      If I find a scenario where we need a certificate on an ESP I will cover also this aspect. So far I did not find one.

    • @pawel753
      @pawel753 Před 5 lety

      @@AndreasSpiess Accessing ESP device web interface isn't this scenario?

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      No, only connecting a web server from the ESP. Of course, the SSL theory applies to both scenarios.

  • @rgmtb
    @rgmtb Před 5 lety

    Wow, this is a pretty complex topic. It’s gonna take some practice to get my head around it for sure.

  • @avejst
    @avejst Před 5 lety

    Fantastic video.
    Thanks for sharing 👍😀

  • @digitalartee
    @digitalartee Před 3 lety

    Great vid !

  • @elmoferguson
    @elmoferguson Před 3 lety +1

    FYI
    Line 31 of Python code is different between what is shown in the video and what the actual code. I found the video version worked.
    On video: hexList = list(''.join(map(chr,hexData)))
    In code: hexList = list(''.join(hexData))

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      Thanks for the correction. Maybe it will help somebody in the future...

    • @JoaoVictor-xi7nh
      @JoaoVictor-xi7nh Před 3 měsíci

      OH MY GOD THIS COMMENT JUST SAVED MY ASS THANK YOU SO MUCH

  • @Dust599
    @Dust599 Před 5 lety +4

    What about power usage? encryption/decryption doesn't happen for free, more power and more data usage...

    • @korishan
      @korishan Před 5 lety

      Ahhhh, I didn't think about that while I was watching. Not such an issue if the device plugged into a wall socket. But if it's powered by a LiPo (or similar), that could make a huge difference

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +3

      There is a post of another viewer (Frank Hessel) which covers that aspect. I did not investigate into the connection times necessary using HTTPS vs. HTTP. HTTPS times definitively are longer. But, if our service providers change, we have no choice:-(

  • @NicksStuff
    @NicksStuff Před 7 měsíci +1

    Would the ESP be abloe to connect to the authority certificate to download the new one (and convert it) when it's expiring in 10 years?

    • @AndreasSpiess
      @AndreasSpiess  Před 7 měsíci +1

      No. You have to do it yourself.

    • @NicksStuff
      @NicksStuff Před 7 měsíci +1

      @@AndreasSpiess Thank you. OTA update it is, then

  • @santorcuato
    @santorcuato Před 5 lety

    Hi Andreas,
    I know that this video is 3 months old but is really difficult to follow you, and sometimes expensive, but ever fun.
    I have tried the example with the ESP32 and everything works fine, but if I'm not wrong, you said that the use of client.setCACert(root_ca); is mandatory.
    Because I'm really old but still a little rebel, I tried the same sketch without setting the root_ca, by simply comment the line.
    And it works and the resulting JSON is exactly the same, point that simplifies a lot the https connection.
    If someone want to try it, not only in the example but in real life, any comment will welcome.
    Thanks for all your effort and enthusiasm!
    Rom

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Maybe they changed the behavior of the library. As mentioned in the ESP8266 example, the certificate is not for the site, it is for you to check if you are connected to the right site. The ESP8266 always returned the string, also w/o a certificate.

  • @akj7
    @akj7 Před 5 lety

    Thanks for the tutorial. I wished i had something similar as i was handling HTTPS connections with Google to get my emails.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I hope you were successful in the end...

    • @akj7
      @akj7 Před 5 lety

      Andreas Spiess, I was.

  • @suisse0a0
    @suisse0a0 Před 5 lety

    If you don't have the ability to use https (like with my with my cheap attiny) I setup up a ssl proxy (look for tls offloading or (I think) tls termination proxy) on a PI (which is my cheap server) to handle the encryption part.
    Two "possibles issues" :
    1) One more potential failure in the chain
    2) I must trust my own network

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      We used these proxies in the past and they work well. I wanted to show that we can do the same only with an ESP. Your method, of course, is still possible and can solve some issues, especially issues with resources on the ESPs

  • @assadon397
    @assadon397 Před rokem

    Thank you so much. In my case, I used the root_ca to secure MQTT, specifically HiveMQ. However, I don't understand if there will be an exchange of symmetric keys or if the esp8266 will simply use this certificate to encrypt payloads to the broker.

    • @AndreasSpiess
      @AndreasSpiess  Před rokem +1

      I am no specialist. So I do not know the details :-(

  • @PaulCavanagh69
    @PaulCavanagh69 Před 5 lety

    Very interesting Andreas, if we could integrate this with wifi manager that could store certificates, the link between esp8266 iot devices with sensors would be more secure.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I think you could do that. But if the certificate is valid for a few years, you probably do not want to change it through WiFimanager.

    • @gte24v
      @gte24v Před 5 lety

      Ah, yes, I think I see the point - being able to change the key without programming. Perhaps that is something that could be added to IotAppStory.com for example?

  • @RobinHilton22367
    @RobinHilton22367 Před 5 lety +3

    Could you not update the keys using OTA updates or a form of external memory?

    • @korishan
      @korishan Před 5 lety

      I was thinking the external memory, using an EEPROM. OTA of the flash might be a bit much if you needed to do it every other week just for a key. imho

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      You can update the keys from the outside. But you should not forget it. Otherwise, you cannot do it anymore ;-)
      I like the idea of longlasting certificates more appealing, though.

  • @lmamakos
    @lmamakos Před 5 lety

    Very nice video. I shall do my best to share the mafia-centric description of PKI trust! I think that in my Home Automation use-case, the ESP8266 and ESP32 devices will have long-lived MQTT-over-TLS sessions established, so the impact of doing the TLS session establishment and public key cryptography won't really be that noticeable. Thanks!

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Thank you! I do not know how MQTT is implemented and I agree if they can keep the connection open you do not have a lot of overhead (other than heap memory).

    • @systpro4
      @systpro4 Před 5 lety

      Have you programmed MQTT-over-TLS on an ESP8266 via the Arduino IDE?
      If so, could you please share the code for that?
      Thanks!

  • @NishantjonyJaiswal
    @NishantjonyJaiswal Před 5 lety +3

    I m gonna watch this multiple times..😴😴

  • @e2Dy
    @e2Dy Před rokem

    Hi Andreas, have you dealt with Matter on ESP32 yet? It might be worth making a video about it. 😊 Sorry for being a little bit off-topic.

    • @AndreasSpiess
      @AndreasSpiess  Před rokem +1

      It is too new for me and currently has no advantage over Zigbee (or even a disadvantage). I will cover it when it has more value, I think.

  • @binershock
    @binershock Před 5 lety

    Just today joined your patreon! - It seems like for a deployment of a device for several years or more, you must create a scheme to replaced expired certs or otherwise the old fingerprints. I guess if this is the plan, you probably have some way to update the whole "sketch" anyway.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Thank you for your Patreon support! You are right, the certificates have to be replaced. Usually after 2020 or 2022. Maybe we will have better possibilities then and can change our sketch accordingly...

  • @sorin.n
    @sorin.n Před 5 lety +2

    I will make now requests to the server it can't refuse... :D

  • @Bigman74066
    @Bigman74066 Před rokem

    As usual, a great video. Hoever, I did miss the part that talks about performance of the asymmetrical (handshake) part of the connection. Depending on the cypher i may take upto 3 seconds to het the connection up and running. When using mqtt this can be a mayor pain in the bottom. I would have loved to have some more info in that since it's hard to find...

    • @AndreasSpiess
      @AndreasSpiess  Před rokem

      I do not use encryption in my LAN.

    • @Bigman74066
      @Bigman74066 Před rokem

      ​@@AndreasSpiess I don't understand. The video is about using SSL on (for example) an ESP32. An SSL connection starts with a handshake that uses asymmetrical encryption. I can be very slow especially if you reconnect every few seconds (MQTT for example). It made using MQTT over SSL nearly impossible for me. Hence my question...

    • @AndreasSpiess
      @AndreasSpiess  Před rokem

      @@Bigman74066 sorry that my answer was so short. what I wanted to say is that I use SSL to contact internet services like google. So I do not need frequent repetition.
      MQTT is only used for my sensors on my Wi-Fi. So the 3 seconds are not a. If Problem for me.

    • @Bigman74066
      @Bigman74066 Před rokem +1

      @@AndreasSpiess thanks for clearifying. Maybe someday a video will pop up about performance of MQTT over SSL on an ESP32. You never know!

  • @electronic7979
    @electronic7979 Před 5 lety

    Useful video 👍 Excellent 👍

  • @RubenKelevra
    @RubenKelevra Před 5 lety +5

    You got that wrong.
    Encryption != Security
    Encryption = secrecy if the encryption is strong.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      I think encryption can be part of a security concept.

    • @RubenKelevra
      @RubenKelevra Před 5 lety

      @@AndreasSpiess a solid authentication is much more worth than encryption. Also a secure handshake and strong random number generators are necessary before you can think of encrypting anything.
      IoT device usually have trouble generating solid random numbers and usually have backdoors or major implementation flaws of the APIs for logins. Just adding encryption is usually just a patch which do not cover the holes below.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I do not understand a lot about the underlying technology. I just want to access some services which do no more accept HTTP requests. I do not transport real secrets with my devices :-)
      Currently, everybody uses HTTP and I thought even a bad implementation of encryption is better than that.
      BTW: Why do you write, that authentication is more valuable than encryption?

    • @RubenKelevra
      @RubenKelevra Před 5 lety

      @@AndreasSpiess authentication is signing your messages cryptographically. Without it your encryption is easily breakable if you're in the middle - which is the assumption for "why we need encryption". For strong authentication and strong encryption you need a good handshake method, and for this to be secure, you need a good source of true random numbers. If an attacker can guess the random numbers you generated for your handshake it's likely that he can decrypt the handshake. With a really badly designed handshake it would also be possible to calculate the private key, after guessing the random numbers.
      So in short random number generators are the first step to implement a secure communication.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      If I understand right, you always need a "man-in-the-middle to "hijack" the connection. So the effort is considerable to inject data to a web request from an ESP using a poor encryption. BTW: A board with a receiver has no problem to get random numbers. Just listen to the receiver on an empty channel (white noise). But I do not know if the ESP library uses this process.

  • @adarshbhosale1374
    @adarshbhosale1374 Před 2 lety +1

    I am trying to get the certificate like above but, its getting any idea to get the certificate?

    • @AndreasSpiess
      @AndreasSpiess  Před 2 lety +1

      This is an old video and a lot changed since then. Maybe you look at the newer example files of the Arduino IDE?

  • @TravisHardiman
    @TravisHardiman Před 5 lety +1

    Is there any disadvantage to putting the certificate.cer into the SPIFFS storage?

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      I do not like SPIFFS for such a small amount of data. You have to upload it separately. The library probably takes more space than the certificate. Otherwise, you can do it.

  • @giannifed
    @giannifed Před 3 lety

    thank you sir

  • @yashpandit832
    @yashpandit832 Před 5 lety +1

    I am using he esp32 WiFiClientSecure library.
    But it does not have a cilent.verify function. Just to check I put a wrong root CA cert and it still connected to the server and gave html data.
    So, am i doing something wrong or if not then how can I verify for the esp32 that I am connected to the server I wish to be connect.
    Thanks in advance.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      This is strange. I thought in my examples this did not work

  • @theUsesOFnot
    @theUsesOFnot Před 4 lety

    How can I connect to https when using an Arduino Nano or a Teensy for example? Or do you have to use an ESP8266 development board/MCU?
    I have an ESP8266 WIFI Module (ESP-01) connected to a Teensy 3.2 board, but when I compile it says "ESP8266WiFi.h cannot be found". If I change the board to "Generic ESP8266" I get an error saying "Multiple libraries were found for ESP8266WiFi.h". So confusing.

    • @AndreasSpiess
      @AndreasSpiess  Před 4 lety

      I only work with ESP boards if I need WiFi, so I do not know,.

  • @berniewolf6740
    @berniewolf6740 Před 5 lety +1

    Nice explanation, and good info. Thanks. Have committed some $$ via Patreon
    I found an error message trying to convert a root cert file to .cer format using Cert to ESP8266.py. Fixed by removing the attempt to map the chr function across the hexData.
    ie:
    replaced this
    #hexList = list(''.join(map(chr,hexData)))
    with this.
    hexList = list(''.join(hexData))

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Thank you for your support! I am not a Python specialist and I found the script on the internet. When I used it I had no errors, if I remember right. Now your code is in the file.

    • @timothynjeru4998
      @timothynjeru4998 Před 4 lety

      Hi Bernie, how did you do this?

    • @ttssoon1975
      @ttssoon1975 Před 4 lety

      Already tested. This should works:
      hexList = list(' '.join(map(chr,hexData)))
      The 2nd not working. Thanks!

  • @Pyrografpl
    @Pyrografpl Před rokem

    Thank you

  • @burmwout5525
    @burmwout5525 Před 4 lety

    If you do not want to bother with manually writing a fingerprint or certificate in your sketch, there is also a framework that automatically includes all root certificates in your ESP8266 sketch. With this you can do HTTPS requests to any URL, and it will always be secure:
    maakbaas.com/esp8266-iot-framework/logs/https-requests/

    • @AndreasSpiess
      @AndreasSpiess  Před 4 lety +1

      Thank you for the link. Seems to be a good approach. Unfortunately not for the ESP32...

  • @feedchequefc682
    @feedchequefc682 Před 5 lety

    Great video as always Andreas. Detailed but not boring. Very good presentation indeed.
    Maybe this goes outside of this video's content since we are talking about the security... how do you handle securing your keys or certificates? After all your 8266 sketch can be read by anyone therefore an attacker can also read the certificate information. Is there a way to secure the certificate or public key info written into the sketch?

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      As the name implies: The public key does not need to be hidden. That was the invention. And I think, the inventors got the Nobel prize for that.

  • @chadreshpatel2339
    @chadreshpatel2339 Před 2 lety

    Many webservers are hosted on cloud where single physical server host many web servers and uses SNI (Server name indication) to resolve the server name. Many small IoT controllers do not support SNI feature. Do you know whether Esp32 libraries support SNI?

  • @winandd8649
    @winandd8649 Před 3 lety

    Couldn't get you example sketches to work, sketch always stops with "connection failed", so the fingerprint was not even checked yet.
    Eventually i added the next line to the sketch (directly after "WiFiClientSecure client;"):
    client.setInsecure();
    Don't know what was wrong with my setup, but it works flawlessly now :-)

  • @jamisusijarvi646
    @jamisusijarvi646 Před 5 lety +1

    What about client certificates? Quite often I want to verify also client in server side with client certificates

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I do not know. I only wanted to access https websites. Maybe you find some other sources for that topic.

    • @jamisusijarvi646
      @jamisusijarvi646 Před 5 lety

      @@AndreasSpiess some HTTPS sites that wants to authenticate client requires client certificates. But yes, it's not so common

  • @fouadkhalifa520
    @fouadkhalifa520 Před rokem

    Hello Andreas, is adding ATECC608 chip to the circuit add any advantage ?

  • @donpalmera
    @donpalmera Před 5 lety

    IMHO TLS on platforms without even basic stuff like memory protection is maybe not totally pointless but only slightly better than it not being there at all. Especially when you have so little memory to start with and the memory pressure created by the TLS library will make it easier to create overflows etc. I say this after having implemented TLS on a Cortex M3 based product with more memory that's out in the wild in a few hundred thousand units... when I think about how many issues the industry-standard OpenSSL had/has I really don't have much hope that any of the embedded TLS libraries, which AFAIK are all based on some old BSD licensed code that was kicking around, being all that good.
    In most applications you'd use a microcontroller for you don't even want the privacy (encryption) bits. You mostly want to validate the source of messages. I think there are cheap i2c secure elements that can do HMAC signing and validation. That seems like a better solution IMHO.
    If you have an upstream service that requires HTTPS it seems to me like a gateway to that service running in the cloud would be better than trying to do it on the ESP itself.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I am no security specialist and I just wanted to show how we can make sure that we still can use our cloud services if they only accept HTTPS connections. Maybe it is not secure, but I cannot change anything because I have no knowledge in this area.
      If you have to build a sellable product this is another story, AFAIK the new Arduinos use such an I2C chip. I also do not understand what the encryption blöocks in the ESP32 do and if they are used by the libraries.

    • @donpalmera
      @donpalmera Před 5 lety +1

      I wasn't being negative about your video. I was being negative about the state of this stuff in IoT in general.
      >we still can use our cloud services if they only accept HTTPS connections.
      Many cloud services seem to assume you have a platform that can do TLS properly. AWS IoT for example requires TLS, device certs etc but didn't take into account that a little microcontroller based IoT thingy might not have the right time. Without the right time TLS is useless and many IoT platforms might only have a time that is within the right month and not within the right day that would be required for the very short expiry certificates AWS, Google etc want to use. There is a disconnect between the service providers and people making stuff that uses the services.
      >AFAIK the new Arduinos use such an I2C chip.
      There are a few examples of it. One of the earliest IoT platforms (electricimp) used an i2c secure element.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      At least the ESP32 example connects to NTP to get the time. Now I know, why :-) Thanks!

  • @drakoky6894
    @drakoky6894 Před 3 lety

    I made a OTA, one time, from a private GitHub repo. On internet I found that was is not possible, but I made it.

  • @Electronieks
    @Electronieks Před 5 lety +14

    My esp32 comes hot when it is connected to your youtubechannel

    • @vincentstragier6628
      @vincentstragier6628 Před 5 lety +4

      Try watercooling.

    • @thisusernameismine10
      @thisusernameismine10 Před 5 lety +3

      Funny, thats what my wife says when she comes into my office on sunday mornings, "ah, you're watching your hardware porn again.." - just revenge for me saying the same when I catch her browsing running shoe websites.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +2

      :-))

  • @wassfila
    @wassfila Před 5 lety

    Great overview, security is a vital topic for IoT and advanced tech is nothing without such good pedagogical presentations. I wonder if it is that easy to have the esp32 as an https server ?

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I think it is possible. However, I do not use encryption behind my firewall.

    • @wassfila
      @wassfila Před 5 lety

      I also would not venture opening up a port for an esp32 through my double routers walls, I use a VPN for that. But the IoT is pushing with things like Thread that standardizes bridging ipv6 sensors to the internet, we'll see how IoT security will evolve.

  • @akj7
    @akj7 Před 5 lety

    You do not need to write a programm to read that file. They are usually read with HEX Editors.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      If you have a close look they need a few characters more at the end of each line...

  • @mitolsteu9274
    @mitolsteu9274 Před 4 lety

    Thank you for the perfect explanation. It is very useful an focuses on the important facts.
    Is there any possiblilty to download the SHA1 fingerprints from a server of website?
    It would be easy to update the fingerprints by stating the URL and getting back the SHA1 fingerprint like in the browser. So the sketch could get it once the fingerprint is expired and I would not need to update it manually.

    • @AndreasSpiess
      @AndreasSpiess  Před 4 lety

      I do not know.

    • @burmwout5525
      @burmwout5525 Před 4 lety

      This would not be secure, because if you would have a man in the middle, it would just provide you with the wrong fingerprint and you would not know.

  • @Mr.Leeroy
    @Mr.Leeroy Před 5 lety

    Call me paranoid, but I struggle to call 'secure' anything less then SoC with OpenVPN for wireless or Internet-facing applications.

  • @markusrohner9452
    @markusrohner9452 Před 4 lety

    Good video. What does "esp8266/Arduino CI has failed") mean? I get 'fd1' as a reply. The certificate verification was successful

  • @elchiqui10
    @elchiqui10 Před 5 lety +1

    You may use HxD hex-editor to convert binary data to C o other programming languages. Simply open the file, select all and copy as => C (the editor is here mh-nexus.de/en/hxd/)

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      True. But if you closely look at the Arduino sketch you see, that you would have to add some stuff by hand. I was too lazy for that.

  • @AndreasDelleske
    @AndreasDelleske Před 2 lety

    Dear Andreas, since this video is already older and I am fighting with micropython on an ESP32, didn't find much in the internets: It would be fantastic if you could try HTTPS requests on micropython :) maybe even with proper certificate checking - or would you suggest CircuitPython? So far, I like Thonny a lot..

    • @AndreasSpiess
      @AndreasSpiess  Před 2 lety

      After my Toit "excursion" I will not cover higher languages for quite some time. The time is just not ripe for mainstream. At least not in this community...

    • @AndreasDelleske
      @AndreasDelleske Před 2 lety

      @@AndreasSpiess Ah OK thanks you for your answer!

  • @niekbeijloos8355
    @niekbeijloos8355 Před 5 lety

    Thank you!

  • @TomaszDurlej
    @TomaszDurlej Před 5 lety

    Consider also https for esp8266/32 in server role. It's pretty easy with reverse proxy and raspberry pi and nginx for example. Some additional config is necessary for separation iot and normal sides of home network.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      So far I do not use encryption behind my firewall (for IOT devices). This video was mainly to ensure we still can use useful cloud services. But if you want to access your ESP from the outside it might be necessary...
      Usually, I use MQTT instead of a web server on the ESP. I find it more appropriate for the small resources of our devices.
      Nginx is on my video list for a long time..

    • @wyzedfz1495
      @wyzedfz1495 Před 2 lety

      I know that this is old but I was strugglin with this as I want to do my IoT devices as secure as possible, keeping in mind good practises.
      Since I have some others (In fact, a lot) ESP servers at home which I want to reach from the outside (All of them are HTTP with basic authentication), I think that my best shot is to build a reverse proxy with a SBC (Probably a raspi), isn't it?
      Whad do you think @Andreas Spiess ? Do you have any vids on this topic?
      Thanks in advance!

  • @koz
    @koz Před 5 lety

    Another very useful video. Thank you!
    But I also think it's important to learn how to provide a secure https connection on the little websites *hosted* on an ESP*.
    All those important little web interfaces, often with username and password fields to access them, etc. - so many 192.168.*.* admin interfaces need to be secure.
    I see that recent updates to the ESP8266 libraries appear to contain a lot more examples for this, such as 'WiFiHTTPSServer', which also contains a script to generate a 'Self-Signed Certificate' to enable your ESP*-hosted website to run via https.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      You are right, you can also encrypt these connections. I usually do not encrypt the traffic behind my firewall and use MQTT for the connection to my ESPs . So I had no need for this scenario so far.

  • @ralfjahns3777
    @ralfjahns3777 Před 5 lety

    Not too many real projekts recently. I know, they cause much more work but I prefer them compared to all the pure educational videos. Nothing beats the reminder device. :-)

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Thanks for the reminder ;-) I try to mix the different things...

  • @Javito379
    @Javito379 Před 5 lety

    Hi, great work as always. So correct me if i am wrong, these rules out self signed certificates?

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Certificate generation is on the server side. This video focuses on the client side and assumes, the server thing is up-and-running. I also did not cover the certification of the ESP device itself as so far, I had no need for that...

  • @KalterKrieger
    @KalterKrieger Před 5 lety

    Hi Andreas, what 8266 core do you recommend? I use 2.4.0 because I had problems with newer ones which consume much more memory that the 2.4.0.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +2

      I did not care too much recently and usually upgrde to the newest version. I only care about memory consumption if I do not have enough ;-)

  • @milicsantiago
    @milicsantiago Před rokem

    great!

  • @RGPinger
    @RGPinger Před 5 lety

    Andreas and what if people are using Arduino + Ethernet shield? :-)
    They are unable to use HTTPS.

  • @narendok2115
    @narendok2115 Před 3 lety

    Hi sir, can we know if we are doing encryption for local IP communication with a smartphone or a web browser with letsencrypt SSL, does it need internet on browser-side : like my local IP ,eg 192.168.4.1. , will be safe ? how we can securely transfer data, should be use cryptography algo etc

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      Unfortunately, I am no security specialist :-(

  • @avejst
    @avejst Před 5 lety

    Wow, interesting subject
    Thanks for sharing 👍😀

  • @akshaydasm.k9388
    @akshaydasm.k9388 Před 3 lety

    Can you please make a video on how to use encryption libraries such as wolfssl with esp32?!

  • @hugob5263
    @hugob5263 Před 5 lety

    Great explanation!! Just one dubt: Who create the symmetric key? The iot device? One of its libraries? Thanks!!!

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      AFAIK public key methods do not symmetric keys

    • @hugob5263
      @hugob5263 Před 5 lety

      @@AndreasSpiess no, of course. Not public key. I'm talking about the symmetric key that iot device and server share encrypted (around 4.10 min in your video). Who generates its?
      Anyway, now, there is a new library/method in arduino so called BearSSL. Can you give us some explanation about?? Thanks!!!

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      I assume the key is generated by the device. I am not sure I will cover BearSSL as I am no specialist here.

  • @browaruspierogus2182
    @browaruspierogus2182 Před 5 lety

    Better and faster is built in esp encryption that can be used with udp/tcp and it is much safer and free)

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      You are right. But the purpose of that video was to enable our devices to use services on the internet even if they change to HTTPS.
      So far, I do not encrypt behind my firewall.

  • @niekbeijloos8355
    @niekbeijloos8355 Před 4 lety

    The code used in HTTPSRequest.ino for the esp8266 is it not outdated? Because I see the BearSSL library is more often used these days and AxTlS library is
    deprecated. Does this matter as to the safety of the connection? Please clarify, thank you!

    • @AndreasSpiess
      @AndreasSpiess  Před 4 lety

      This is an old video. BearSSL does not change the basic concept. So there should be no difference in security.

  • @MPElectronique
    @MPElectronique Před 2 lety

    Andrea : in esp8266 python error:
    CertToESP8266.py", line 31, in
    hexList = list(''.join(hexData))
    TypeError: sequence item 0: expected str instance, int found
    :(
    thanks for help
    marc.

    • @AndreasSpiess
      @AndreasSpiess  Před 2 lety +1

      I do not use MicroPython on the ESP8266. Maybe you google?

    • @MPElectronique
      @MPElectronique Před 2 lety

      @@AndreasSpiess but you did write the script to convert certificate to string.

    • @MPElectronique
      @MPElectronique Před 2 lety +1

      Hello. i found the error : replace hexList = list(. ..... by:
      hexList = "".join(map(str, hexData))
      :)

  • @tastenklopper3038
    @tastenklopper3038 Před 3 lety

    This is the first video I am watching from this channel. I want to stream my ESP32 Cam remotely. When he says "the rest of the code stays the same", what code does he mean? It looks a lot different than the example camera code.

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      I do not know the ESP32 cam and if it uses the http protocol :-(

  • @LearnMakeShare
    @LearnMakeShare Před 3 lety

    I've tried converting espressif arduino-esp32 camerawebserver project from http to https with little luck. Do you know of examples that might help?

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      No, I never tried it. And the https stuff recently changed in the ESP32 framework. So you have to use the newest examples, I think.

  • @CreativeJE
    @CreativeJE Před 4 lety

    hey is there any easy way we can make https requests without any fingerprint cause we will need to update the fingerprint everytime it changes and it won't be a good idea

    • @AndreasSpiess
      @AndreasSpiess  Před 4 lety

      I am no internet security specialist, so I do not know.

  • @SThomas1972
    @SThomas1972 Před 5 lety

    Why not store the X.509 cert on flash or a SD card so the cert is not hard coded in the sketch so using the card so the cert is read from it and if they are changed because they they have expired.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      This is possible, of course. But if they expire in 4 years I do not care too much...

  • @superliegebeest544
    @superliegebeest544 Před 2 lety

    Hello sir, u make some great videos.
    I cant wrap my head around the following concept. Maby you or anyone else out here could point me in the right direction.
    Wat I am working on is the following,
    I am building a vendingmachine thats controlled by an ardiuno. I want it to work as followed, a customer goes to my website on their phone, this opens a webstore so they select the products into the basket and pay online witj ewallet or online bank. Just like any other webstore, than the webstore needs to send.the data after payment verification to the andrino that gives out the product. I understand I can connect it with utp to the internet, but what protocol or software I use on the website to instruct the arduino? Or would it be easier to use a phi that hosts the webstore, and connects via lan to the.andrinos?

    • @AndreasSpiess
      @AndreasSpiess  Před 2 lety

      I would divide your project in parts and build one part after the other.

  • @J3zp3rs
    @J3zp3rs Před 4 lety

    Hello Andreas thank you very much for the video. Although i have a problem, when i put in the certificate and make a const char for it i get this error: no matching function for call to 'BearSSL::WiFiClientSecure::setCACert(const char*&)' please help me!

    • @AndreasSpiess
      @AndreasSpiess  Před 4 lety

      Your function is different to mine I did not use BearSSL. And I do not know how it works because I never tried it.

  • @hikuri3500
    @hikuri3500 Před 5 lety

    great tutorial is there any way to do this in AP mode, do you know any tutorial, link or information about it ?, I feel lost

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      Maybe here: github.com/fhessel/esp32_https_server

  • @sandipkumarnandi
    @sandipkumarnandi Před 3 lety

    Thanks for the explanation, but I tried the same way to call my https service, which is showing error code -1 with https.
    Any guidance would be greatly be helpful

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      Quite a lot changed since I made this video. So it might no more be up-to-date

  • @lomolariful
    @lomolariful Před 5 lety

    Vpn might only be helpful in cases where you own the endpoint of the connection as well, if i'm not wrong. But i'm asking myself if its possible to access a local proxy server via http and let it do the heavy https stuff with the outside world?

    • @Steve_Coates
      @Steve_Coates Před 5 lety

      It is but it leaves your IOT devices vulnerable to local attack, personally I don't want anyone else able to access my cameras, heating controls etc. nor do I want to leave any easy entry point into my home network. I use ssl on all my gadgets even though everything external is handled by a proxy.

  • @overite
    @overite Před rokem

    please how can i make my sim800 communicate with SSL/TLS1.3

    • @AndreasSpiess
      @AndreasSpiess  Před rokem

      I do no more use the SIM800 because it does not support 4G

  • @alphabet340
    @alphabet340 Před 2 lety

    Hello Andreas, is there a possibility to nurzen this SSL encryption via LAN, for example. with ethernet.h?
    Many greetings

    • @AndreasSpiess
      @AndreasSpiess  Před 2 lety

      I do not know, I never needed it.

    • @alphabet340
      @alphabet340 Před 2 lety

      @@AndreasSpiess Thank you for your reponse.
      It's a shame, I currently have a project in which I want to communicate https post via a server. Unfortunately, I can't find any suitable examples. Http alone wouldn't be a problem.

  • @pschach
    @pschach Před 3 lety

    Hello Andreas,
    I am having trouble getting your python script to work properly. I loaded it into my Raspberry and ran it in the same folder as my ca.crt file (also tried changing the name to ca.cer). I ge this error:
    python CertToESP32.py
    // ca.crt
    const char* test_root_ca = \
    Traceback (most recent call last):
    File "CertToESP32.py", line 39, in
    first = (chr(content[i]))
    TypeError: an integer is required
    The certificate is in the right format with -----BEGIN CERTIFICATE-----, but it doesn't have those nice /n at the end and hasn't been adjusted. I guess that is the purpose of your script! By the way, I created my certificates using OpenSSL

    • @AndreasSpiess
      @AndreasSpiess  Před 3 lety

      This is an old project. So it is possible the code does not work anymore.

    • @pschach
      @pschach Před 3 lety

      @@AndreasSpiess Okay, thanks for letting me know! I suppose I can manually count the characters and hit ENTER a few times for the two certificates I need.

  • @germandkdev
    @germandkdev Před 5 lety

    What about secure SSL connections with a esp only, not the www? I mean you can't create a certificate for the random esp ip etc?

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety

      The scenario covered in this video was purely connecting an ESP to an HTTPS address. There are many more scenarios thinkable, but so far I never encountered one.

  • @Zhaymoor
    @Zhaymoor Před 5 lety +2

    How do you learn all that man ,, Mashallah you are so amazing at this,, I really want to visit Swiss land to meet you ! thank you for the great content.

    • @AndreasSpiess
      @AndreasSpiess  Před 5 lety +1

      It is very easy to learn stuff: Curiosity also in my age and hard work ;-)