How to test Certifications on ESP32C3 AT

ShahinHaque
Posts: 17
Joined: Mon Oct 31, 2022 12:10 pm

How to test Certifications on ESP32C3 AT

Postby ShahinHaque » Fri Jan 06, 2023 12:36 pm

Lets say I have a site that requires a certificate, I can import that certificate to the ESP32C3 via ESP FLASH DOWNLOAD TOOL to it's respective memory locations. Is there a function that can check if the certificate is valid?

ESP_Sun
Posts: 320
Joined: Thu Dec 30, 2021 9:52 am

Re: How to test Certifications on ESP32C3 AT

Postby ESP_Sun » Mon Jan 09, 2023 2:43 am

ShahinHaque wrote:
Fri Jan 06, 2023 12:36 pm
Lets say I have a site that requires a certificate, I can import that certificate to the ESP32C3 via ESP FLASH DOWNLOAD TOOL to it's respective memory locations. Is there a function that can check if the certificate is valid?
Hi,

Maybe you can try to create an SSL connection using openssl. First verify that your certificate is valid. If you can use the certificate to create an SSL connection using openssl normally, your certificate should be valid. Therefore, you can refer to this example(https://docs.espressif.com/projects/esp ... entication) and use the AT command to try to create an SSL connection to see if the connection can be created successfully?

ShahinHaque
Posts: 17
Joined: Mon Oct 31, 2022 12:10 pm

Re: How to test Certifications on ESP32C3 AT

Postby ShahinHaque » Mon Jan 09, 2023 3:16 pm

Code: Select all

openssl s_client -connect website_name.com:443 -CAfile C:\Users\Shahin.Haque\Downloads\Root_CA_B64.cer


..
SSL handshake has read 2745 bytes and written 453 bytes
Verification: OK
..
..
..
Timeout   : 7200 (sec)
Verify return code: 0 (ok)
vs

Code: Select all

openssl s_client -connect website_name.com:443


verify error:num=19:self-signed certificate in certificate chain
verify return:1
..
..
..
SSL handshake has read 2745 bytes and written 453 bytes
Verification error: self-signed certificate in certificate chain
..
..
..
Timeout   : 7200 (sec)
Verify return code: 19 (self-signed certificate in certificate chain)
..
..
..
Above caption from OPENSSL, this is what I expected. An error without the file and verified with.

Now that I have varied that this works, I no longer need OPENSSL, the rest should be able to be done on the ESP32C3.

Using:

Code: Select all

/* AT CALLBACK */
AT+CIPSTART="SSL","wesbite_name.com",443
I get

Code: Select all

CONNECT
OK

/* ESP CALLBACK */
cert len=1164
set cert&key ok
ssl established

Which looks like it is working perfectly, however I get that reply with my cert aswell as the esp cert, which should only work with my cert. Furthermore regardless of the date I get an OK response.

I have tried removing the key aswell as making a fake key to see if it passes, but thankfully that fails

Code: Select all

/* AT CALLBACK */
ERROR

/* ESP CALLBACK */
cert len=0
ssl create 0 socket fail



Commands send to the ESP

Code: Select all

AT+RESTORE

AT+CWMODE=1

AT+CWJAP="wifi_name","wifi_password"

AT+CIPSNTPCFG=1,8,"cn.ntp.org.cn","ntp.sjtu.edu.cn"

AT+CIPSNTPTIME? (to check the date is set)

AT+CIPSSLCCONF=3,0,0 (Have also tried 1,0,0 & 2,0,0 arrangements)

AT+CIPSTART="SSL","wesbite_name.com",443



Any ideas?

ShahinHaque
Posts: 17
Joined: Mon Oct 31, 2022 12:10 pm

Re: How to test Certifications on ESP32C3 AT

Postby ShahinHaque » Mon Jan 09, 2023 4:33 pm

I think I may be onto something, I have the CA file rather than the Cert+Key.

Am I correct in saying I need the CA or (CERT+KEY) but not both?
If so what command would I need to use to change it to CA?

Who is online

Users browsing this forum: No registered users and 40 guests