How to use the sntp protocol on the ESP8266 to connect to a server in ssl?
How to use the sntp protocol on the ESP8266 to connect to a server in ssl?
Postby Clancys » Mon Jul 23, 2018 6:11 pm
Hello,
I am using an ESP8266 with the esp-open-sdk with the C language.
I have tried to use this code to get the timestamp but it is failing everytime - I am only getting 0 :
sntp_set_timezone(2);
sntp_setservername(0, "fr.pool.ntp.org");
sntp_init();
timestamp = sntp_get_current_timestamp();
os_printf("time : %d and %s\n", timestamp, sntp_get_real_time(timestamp));
As you may have understand from the subject, i am trying to connect to a server to do an https request (i am using the espconn_secure_*** functions) but it is failing everytime.
It may be because of the time (can't authenticate the certificate because of the validity over time) or because of a non-supported protocol. The TLS protocol is used for the secure transaction, the server is using TLSv1.2 and i read on internet that the ESP8266 was only supporting TLSv1.1; Is that right?
Another strange thing is that after i try to establish the tcp connection, i get the timestamp correctly.
You can see next how i am trying to connect to the server - at address 0x70000 there is the CA of the server i am trying to connect the ESP:
espconn_secure_ca_enable(1, 0x70);
espconn_secure_connect(&conn);
Am i using espconn_secure_ca_enable correctly? Am i giving him the correct document to process? Is this function necessary?
Any remarks or commentary are highly appreciated.
Clancys
I am using an ESP8266 with the esp-open-sdk with the C language.
I have tried to use this code to get the timestamp but it is failing everytime - I am only getting 0 :
sntp_set_timezone(2);
sntp_setservername(0, "fr.pool.ntp.org");
sntp_init();
timestamp = sntp_get_current_timestamp();
os_printf("time : %d and %s\n", timestamp, sntp_get_real_time(timestamp));
As you may have understand from the subject, i am trying to connect to a server to do an https request (i am using the espconn_secure_*** functions) but it is failing everytime.
It may be because of the time (can't authenticate the certificate because of the validity over time) or because of a non-supported protocol. The TLS protocol is used for the secure transaction, the server is using TLSv1.2 and i read on internet that the ESP8266 was only supporting TLSv1.1; Is that right?
Another strange thing is that after i try to establish the tcp connection, i get the timestamp correctly.
You can see next how i am trying to connect to the server - at address 0x70000 there is the CA of the server i am trying to connect the ESP:
espconn_secure_ca_enable(1, 0x70);
espconn_secure_connect(&conn);
Am i using espconn_secure_ca_enable correctly? Am i giving him the correct document to process? Is this function necessary?
Any remarks or commentary are highly appreciated.
Clancys
Re: How to use the sntp protocol on the ESP8266 to connect to a server in ssl?
Postby Clancys » Wed Nov 28, 2018 5:23 pm
Hello back,
I have finally found what was happening.
You almost have to do exactly what Espressif is doing in their example,
the SNTP function needs some time given through the os_timer_...
Then you just have to wait for the sntp to get the time and
you can use the ssl function as much as you want.
Clancys.
I have finally found what was happening.
You almost have to do exactly what Espressif is doing in their example,
the SNTP function needs some time given through the os_timer_...
Then you just have to wait for the sntp to get the time and
you can use the ssl function as much as you want.
Clancys.
Re: How to use the sntp protocol on the ESP8266 to connect to a server in ssl?
Postby Her Mary » Tue Jan 29, 2019 5:31 pm
That's true. SSL certificate will have an expire date, so you need to get the sntp time at first to see if the SSL certificate expired. Otherwise the SSL will fail.
Re: How to use the sntp protocol on the ESP8266 to connect to a server in ssl?
Postby elimark1 » Sat Sep 04, 2021 6:02 am
As you may have understand from the subject, i am trying to connect to a server to do an https request (i am using the espconn_secure_*** functions) but it is failing everytime.
It may be because of the time (can't authenticate the certificate because of the validity over time) or because of a non-supported protocol. The TLS protocol is used for the secure transaction, the server is using TLSv1.2 and i read on internet that the ESP8266 was only supporting TLSv1.1; Is that right?
It may be because of the time (can't authenticate the certificate because of the validity over time) or because of a non-supported protocol. The TLS protocol is used for the secure transaction, the server is using TLSv1.2 and i read on internet that the ESP8266 was only supporting TLSv1.1; Is that right?
Re: How to use the sntp protocol on the ESP8266 to connect to a server in ssl?
Postby Her Mary » Fri Sep 10, 2021 11:10 am
Could these SSL and HTTPS examples help? https://github.com/espressif/ESP8266_RT ... /protocols
Re: How to use the sntp protocol on the ESP8266 to connect to a server in ssl?
Postby alenrexy » Thu Sep 16, 2021 8:01 pm
thank for the hands up
bless you

Who is online
Users browsing this forum: No registered users and 3 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.