WiFiClientSecure doesn't work in Espressif 32 v3.1.0

I recently upgraded my ESP32 platform to 3.1.0 and noticed that WiFiClientSecure doesn’t work properly.
I see this error in the console when trying to connect to a socket.
[E][WiFiClientSecure.cpp:127] connect(): start_ssl_client: -1

I downgraded the project to 3.0.0 and works just fine.
Kind regards, Reza


What is the full platformio.ini and minimal code to reproduce the issue?

I have the same problem with 3.1.0 and 3.1.1. I downgraded the project to 3.0.0.
PS: I’m using google iot core library

1 Like

I used the very basic example of Google Home Notifier.
Works perfectly in Ardunio but not in PlatformIO if I target 3.1.1

And what version of the ESP32 Arduino core do you have installed in the Arduino IDE, per the Arduino board manager?

I have a feeling that I can’t reproduce this since it requires a Google Home thingy that I don’t have, so more info or a minimal example that has nothing to do with Google Home needs to be given.

I have the same problem here, downgrading to 3.0.0 also worked for me. The problem must have crept into version 3.1.0, since that does not work either.
In my case I try to connect to my own private server (raspberrypi) using self-signed certificates.
I have localized the problem in ssl_client.c when performing a SSL handshake. I then get an errorcode -9984 (invalid certificate or signature), thus the problem is somewhere in mbedtls_ssl_handshake() or in functions being called by mbedtls_ssl_handshake().

I use self-signed certificates with a root-ca and an intermediate ca, all three of my certificates are still valid.

Can you check that please?

Hey Max,

Sorry for the late reply.
I tested with espressif32@3.2.0 the same issue!
I have Arduino v1.8.13 installed. The VS code says, the macro value is10805
and I have esp id 3.3.5-1-g85c43024c

Here is the very minimum code to reproduce it, but I guess you still need a Google Assistant compatible speaker.

But what does the board manager say about the ESP32 core version?


(here e.g 1.0.4 is isntalled).

Now, we are getting somewhere I think.
I had the same 1.0.4 installed. and tested it with 1.0.5 and 1.0.6 they don’t work!

So it is caused by the Arduino core version.

Arduino core 1.0.4 is first used in Espressif32 platform 1.11.0 up and including to 3.0.0 (release pages).

Can you confirm it works with PlatformIO again if you change


platform = espressif32@3.0.0


Yes, it does work when I retarget it to 3.0.0

Okay, great! That’s Arduino core terroritory then. Please file a bug at Issues · espressif/arduino-esp32 · GitHub.

EDIT: Cause seems to be explained in Latest Core Breaks WiFiClientSecure Insecure HTTPS · Issue #4992 · espressif/arduino-esp32 · GitHub, Arduino core changed its behavior.

Yes, that’s very true.