Skip to content

WiFiClientSecure GoDaddy SSL Certificates - CA verification failure #571

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

Closed
liqngliz opened this issue Aug 9, 2017 · 3 comments
Closed

Comments

@liqngliz
Copy link

liqngliz commented Aug 9, 2017

Hardware:

Board: ESP32 DEVKIT V1 DOIT / ESP32 Dev Module
Core Installation/update date: 24/jun/2017
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

Trying to connect with HTTPS and the WiFiClientSecure library to my Go Daddy hosted site. SSL cert is issued by Go Daddy. The connection does not establish Go Daddy CA cert. I tested on the example site www.howsmyssl.com the CA is verified without problems.

I am using the root certificate downloaded through firefox when I go to https://irigapi.com.

Sketch:

WiFiClientSecure (with Go Daddy)

/*
Wifi secure connection example for ESP32
Running on TLS 1.2 using mbedTLS
*/

#include <WiFiClientSecure.h>

const char* ssid = "mySSID"; // your network SSID (name of wifi network)
const char* password = "myPASS"; // your network password

const char* server = "www.irigapi.com"; // Server URL

// www.howsmyssl.com root certificate authority, to verify the server
// change it to your server root CA
// SHA1 fingerprint is broken now!

const char* test_root_ca=
"-----BEGIN CERTIFICATE-----\n"
"MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx\n"
"EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT\n"
"EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp\n"
"ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz\n"
"NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH\n"
"EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE\n"
"AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw\n"
"DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD\n"
"E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH\n"
"/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy\n"
"DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh\n"
"GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR\n"
"tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA\n"
"AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE\n"
"FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX\n"
"WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu\n"
"9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr\n"
"gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo\n"
"2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO\n"
"LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI\n"
"4uJEvlz36hz1\n"
"-----END CERTIFICATE-----\n";

// You can use x.509 client certificates if you want
//const char* test_client_key = ""; //to verify the client
//const char* test_client_cert = ""; //to verify the client

WiFiClientSecure client;

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
delay(100);

Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
WiFi.begin(ssid, password);

// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
// wait 1 second for re-trying
delay(1000);
}

Serial.print("Connected to ");
Serial.println(ssid);

client.setCACert(test_root_ca);
//client.setCertificate(test_client_key); // for client verification
//client.setPrivateKey(test_client_cert); // for client verification

Serial.println("\nStarting connection to server...");
if (!client.connect(server, 443))
Serial.println("Connection failed!");
else {
Serial.println("Connected to server!");
// Make a HTTP request:
client.println("GET https://www.irigapi.com/HTTP/1.0");
client.println("Host: www.irigapi.com");
client.println("Connection: close");
client.println();

while (client.connected()) {
  String line = client.readStringUntil('\n');
  if (line == "\r") {
    Serial.println("headers received");
    break;
  }
}
// if there are incoming bytes available
// from the server, read them and print them:
while (client.available()) {
  char c = client.read();
  Serial.write(c);
}

client.stop();

}
}

void loop() {
// do nothing
}

Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here 

ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0008,len:8
load:0x3fff0010,len:160
load:0x40078000,len:10632
load:0x40080000,len:252
entry 0x40080034
Attempting to connect to SSID: L4T-STAGE
.[D][WiFiGeneric.cpp:182] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:182] _eventCallback(): Event: 4 - STA_CONNECTED
..[D][WiFiGeneric.cpp:182] _eventCallback(): Event: 7 - STA_GOT_IP
Connected to L4T-STAGE

Starting connection to server...
[I][ssl_client.cpp:45] start_ssl_client(): Free heap before TLS 165656
[I][ssl_client.cpp:47] start_ssl_client(): Starting socket
[I][ssl_client.cpp:75] start_ssl_client(): Seeding the random number generator
[I][ssl_client.cpp:84] start_ssl_client(): Setting up the SSL/TLS structure...
[I][ssl_client.cpp:97] start_ssl_client(): Loading CA cert
[I][ssl_client.cpp:153] start_ssl_client(): Performing the SSL/TLS handshake...
[E][ssl_client.cpp:25] handle_error(): X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
[E][ssl_client.cpp:27] handle_error(): MbedTLS message code: -9984
[E][WiFiClientSecure.cpp:102] connect(): lwip_connect_r: 11
[I][ssl_client.cpp:204] stop_ssl_socket(): Cleaning SSL connection.
Connection failed!

@copercini
Copy link
Contributor

looks like the same issue of #550

I promised to fix it, but working with BLE left me with no free time for anything =(

@me-no-dev
Copy link
Member

@copercini I would rather you support this lib as priority. Building a new lib takes a lot longer ;)

copercini added a commit that referenced this issue Aug 24, 2017
Server Name Indication (SNI) support for WiFiClientSecure

Fix #571 and #550
@copercini copercini mentioned this issue Aug 24, 2017
copercini added a commit that referenced this issue Aug 24, 2017
Server Name Indication (SNI) support for WiFiClientSecure

Fix #571 and #550
@copercini
Copy link
Contributor

@liqngliz Should be fixed now =)

Raienryu97 pushed a commit to Raienryu97/arduino-esp32 that referenced this issue Aug 24, 2017
Server Name Indication (SNI) support for WiFiClientSecure

Fix espressif#571 and espressif#550
turmary pushed a commit to Seeed-Studio/Seeed_Arduino_atWiFiClientSecure that referenced this issue Jan 22, 2020
Server Name Indication (SNI) support for WiFiClientSecure

Fix espressif/arduino-esp32#571 and espressif/arduino-esp32#550
blue-2357 pushed a commit to blue-2357/arduino-esp32 that referenced this issue Jul 17, 2024
Server Name Indication (SNI) support for WiFiClientSecure

Fix espressif/arduino-esp32#571 and espressif/arduino-esp32#550
dash0820 added a commit to dash0820/arduino-esp32-stripped that referenced this issue Mar 10, 2025
Server Name Indication (SNI) support for WiFiClientSecure

Fix espressif/arduino-esp32#571 and espressif/arduino-esp32#550
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants