-
Notifications
You must be signed in to change notification settings - Fork 7.6k
ESP32 resets when verifying certificate #657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Let me try understand: You are trying make your ESP32 verify if your server is the legit one, right? |
Hi @copercini , yes that's correct. In the process of creating the certificates, I ended up with 6 files as follows;
|
So you don't need any certificate on ESP32... The ESP is crashing due Anyway, if server certificates are correct installed in the MQTT broker (take a look in the guide bellow), client.setCACert() should works with rootCA.pem to verify the legitimacy of the server, or you can simply doesn't set any cert and this will be encrypted anyway (with someone...) There is a quick guide and a script to install and configure mosquitto with self-signed certificates or with let's encrypt FREE SSL certs |
Hi @copercini, thanks for your response. I believe the server certificates are correctly installed. If I use MQTT.fx to connect to my broker I must specify the same rootCA.pem file or it won't connect. The same for using node-red, I must specify the rootCA.pem file or it will not connect too. Thank you for your help, and great work with the ESP32. |
sorry for posting into a closed issue, but could we still verify the server cert fingerprint on the ESP32 for MITM prevention? |
@everslick The fingerprint mechanism used in ESP8266 is nothing more than a SHA-1 hash sum of ASN.1 binary (DER) form of the CA certificate. In simple terms it's a compacted form of original cert, which uses less flash space to store, less heap, keep the code easier to read and so on.... So, why it's not implemented in ESP32? There are alternatives to SHA-1, like SHA-256 or SHA-3, but how ESP32 has the capacity to deal with the whole certificate, it's more secure, and maybe more easy than get a certificate and generate it's hash. Obviously I'm just a contributor that helps with some code in my free time, so it's just what I think about it and not official anything |
Hi @copercini, thank you for your explanation of the potential security issues using SHA-1/fingerprint for security. In some ways I agree and also disagree with the decision to remove it (or not add it) in the ESP32 code base. Here are some of my reasons...
Due to rootCA problems I am having (only with ESP32), I am now simply ignoring (not using any) certificate but still use TLS/SSL. This is less secure than using a fingerprint verification. I wish I knew more about how to write libraries so I could add my own fingerprint code, or at least understand why I have the problems that I do and where to look in the core code to find them. Please keep up the great work! Without people like you doing all the wonderful and helpful work you do, there would not be people like me trying to learn more and more. |
Sorry to post in a closed thread, but I am still stuck. I want to connect my esp32 with my secure MQTT server. I am using self singed certificate. I used MQTT.fx and connect it with my mqtt server by providing rootCA, client certificate and private key. But when i tried to connect my esp32 using mentioned certificate, I failed and got "certificate not matching" error. |
Most likely your CN in the certificate does not match how you are connecting from the client. If you use an IP address, you must have that IP address listed as an alternate CN. |
Hardware:
Board: ESP32 DevKit V1
Core Installation/update date: 22/Sept/2017?
IDE name: Arduino IDE1.8.3, Mac OS,IDF component?
Flash Frequency: 40Mhz
Upload Speed: 921600
Description:
I am trying to use WiFiClientSecure with a self signed certificate.
I have put my 'server' certificate in my code (not a rootCA as there is not one for self signed), and set the certificate as in the code below.
I have enabled debug output and can see the certificate gets verified then I get the Guru Meditation Error and device reboots.
I tried using
Serial.printf("SSL error was: %u\n", client.errorCode());
which is a snippet I found in one of the previous issues, but the compiler fails giving me the errorclass WiFiClientSecure has no member named errorCode
.Sketch:
Debug Messages:
Backtrace decode
The text was updated successfully, but these errors were encountered: