🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Retrieving data over HTTPS (M5 Paper, but I think this is a generic question)

    Arduino
    5
    9
    7.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Hamnet
      last edited by

      I'm sure this is basic but it's driving me crazy. I can retrieve data over wifi from an "http:" source with no problem. But I can't figure out how to access a URL over https.

      All the examples I can find online - for Arduino, ESp32, or M5 - seem to use http: URLs in their demos. I've found references to WifiClientSecure, but not a usable example. Evidently simply substituting it for WifiClient is not sufficient!

      The canvas.drawJpgUrl function works with an "https:" URL, so clearly there is no fundamental difficulty.

      Googling led me to this excellent library "Fetch": but alas the examples don't compile, a problem others have noted.

      Probably part of the problem is the number of different libraries with similar or even identical names, and different versions of the same library.

      Please can someone recommend the current best (or at least good!) library to use, and point me at a working example?

      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • H
        Hamnet
        last edited by

        (I should add - as a temporary workaround I can access an https: resource by calling client.setInsecure(); but I'm looking for a proper solution.)

        1 Reply Last reply Reply Quote 0
        • felmueF
          felmue
          last edited by

          Hello @Hamnet

          the 'Fetch' library doesn't compile for me either. But I found this example from in the official Espressif github repository which compiles and runs fine.

          Thanks
          Felix

          GPIO translation table M5Stack / M5Core2
          Information about various M5Stack products.
          Code examples

          ajb2k3A H 2 Replies Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3 @felmue
            last edited by

            @felmue from what I have found, there seams to be an issue with https:// based access in Micropython and Arduino. Without knowing more I would guess it is to do with Certificates and security keys.

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            1 Reply Last reply Reply Quote 0
            • H
              Hamnet @felmue
              last edited by

              @felmue Thanks Felix, that got me over the hump! I think the issue was trying to convert my existing example directly.

              1 Reply Last reply Reply Quote 0
              • H
                Hamnet
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • konacurrentsK
                  konacurrents
                  last edited by

                  I have the WiFiClientSecure working to call a https at my cloud site running node-red.

                  Follow these steps:

                  https://randomnerdtutorials.com/esp32-https-requests/

                  What I cannot figure out is how to keep this connection open as it takes about 3 seconds to make a call. My MQTT is much faster.

                  1 Reply Last reply Reply Quote 0
                  • C
                    casascius
                    last edited by

                    I had the same problem and was able to resolve it. I'm using a made-up CA certificate, which in turn was used to sign a server key for my MQTT server. I found all of these steps to be necessary to get WiFiClientSecure to talk to it without needing to call setInsecure().

                    • Provide that CA certificate to the WiFiClientSecure class by calling setCACert()
                    • Access the remote host through its DNS name, not an IP address. (It looks like ESP32 can find it either through traditional a DNS server, or by multicast mDNS such as yourhostname.local if it's on the same network)
                    • The DNS name must be listed as a "DNS" entry in Subject Alternative Name section of the certificate on the remote host. (I was able to use ChatGPT4 to walk me through creating the openssl "conf" file needed to generate a Certificate Signing Request and then ultimately the Certificate that met this criterion).
                    konacurrentsK 1 Reply Last reply Reply Quote 0
                    • konacurrentsK
                      konacurrents @casascius
                      last edited by

                      @casascius Interesting. In my case I'm using real certs from my cloud and it works. I don't know how a DNS name would work outside of localhost names.

                      My main issue stated above was that I want a connection to stay open, and I wasn't able to figure that out.

                      thanks.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post