SSL on ESP32

Posted on
  • Is SSL available on ESP32? I know it wasn't at one point. If not, does anyone know URL/service that can be used to translate?

    I'm trying to pull information from https://firebaseio.com

    I get out of memory error, and have tried turning off bluetooth with no avail. Perhaps I should look into building my own?

    Using version 2.01.

    Thank you in advance.

  • The esp32 build supports https.

    That dns name does not resolve:

    https://firebaseio.com/ - in the browser it for sure if you prefix with www.

    It looks like it's next trying to do some login/authentication - they might be quite tricky...

  • Please post your code, a simple example would be best.

  • Hi - thank you for any help you might provide. Dev board is running other code, so I pulled this from notes, not a working board.

    const SURLAPI = 'https://i66toll.firebaseio.com/eb/belt/washington/tolls.json?orderBy=%22$key%22&limitToLast=1';
    const HTTP = require("http");
    //ESP32.enableBLE(false);
    
    function onInit()
    {
    	//console.log("main");
    	//loadTolls();
    }
    
    var options = {
        host: 'i66toll.firebaseio.com', // host name
        port: 443,            // (optional) port, defaults to 80
        path: '/eb/belt/washington/tolls.json',           // path sent to server
        method: 'GET',       // HTTP command sent to server (must be uppercase 'GET', 'POST', etc)
        protocol: 'https:',   // optional protocol - https: or http:
        headers: { orderBy : "%22$key%22", limitToLast : 1 } // (optional) HTTP headers
      };
    
    function loadTolls()
    {
    	//getting weather now, so allow another process to get weather
      
    	HTTP.get(options, function(res) 
    	{
    		res.on('data', function(wunderString)
            {
              loadTolls.val = wunderString;
              console.log(wunderString);
              memUsage();
            });
    		res.on('close', function(fLoaded)
    		{
              memUsage();
    		});
    		res.on('error', function(e){console.log("error getting URL details");});	//TODO: test, and handle by saving values?
    	});
    }
    
    function memUsage()
    {
      console.log(process.memory().usage);
    }
    
  • Hi,

    Looking at your code above - the headers is not doing what you think it is... - the parameters need to be part of the path.

    path: '/eb/belt/washington/tolls.json?orderBy=%22$key%22&limitToLast=1',

    Without this you get 600k of data back and this is too much!

    However - this is not the issue.

    It looks like since the esp-idf version of the mBed TLS was added that https is no longer working... This simple case fails:

    var http = require("http");
    http.get("https://www.google.com", function(res) {
      res.on('data', function(data) {
        console.log(data);
      });
    });
    

    Added a new issue:

    https://github.com/espruino/Espruino/issues/1613

  • As you can see BOTH the ESP32 (in this case an ESP32-CAM module) and a D1 Mini ESP8266 BOTH where able to connect httpS://google.com successfully

    so v2.04 of Espruino for both of these works perfectly with SSL.

    Hopefully we can close this issue in Github and mark this thread as (SOLVED)

    for those interested in playing along here's the code for copying and pasting:

    var ssid = '***';
    var password = '****';
    var port = 80;
    var wifi = require('Wifi');
    
    
    console.log("started");
    wifi.connect(ssid, {password: password}, function() {
        console.log('Connected to Wifi.  IP address is:', wifi.getIP().ip);
        var http = require('http');
    
        http.get("https://www.google.com", function(res) {
          res.on('data', function(data) {
            console.log(data);
          });
        });
        // wifi.save(); // Next reboot will auto-connect
    });
    
    

    2 Attachments

    • ESP32.png
    • ESP8266.png
  • For my ESP-WROOM-32 it doesn't work.
    And the ESP8266 uses http, even if you specify https.

  • If - or - since it is working: how much space / vars is / are left for the app?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

SSL on ESP32

Posted by Avatar for Will @Will

Actions