SSL compile error

AlonX
Posts: 2
Joined: Thu Mar 19, 2015 9:33 am

SSL compile error

Postby AlonX » Tue Apr 21, 2015 12:04 pm

Hi Espressif:
i add the ssl library to my project, but it is some compiler error
../lib/libssl.a(ssl_loader.o): In function `ssl_obj_free':
(.irom0.text+0x4c0): undefined reference to `default_private_key'
../lib/libssl.a(ssl_loader.o): In function `ssl_obj_free':
(.irom0.text+0x4c4): undefined reference to `default_private_key_len'
../lib/libssl.a(ssl_loader.o): In function `ssl_obj_free':
(.irom0.text+0x4c8): undefined reference to `default_certificate_len'
../lib/libssl.a(ssl_loader.o): In function `ssl_obj_free':
(.irom0.text+0x4cc): undefined reference to `default_certificate'
collect2: error: ld returned 1 exit status
make: *** [.output/eagle/debug/image/eagle.app.v6.out] Error 1


please give me some advice,thanks!

ESP_Faye
Posts: 1638
Joined: Mon Oct 27, 2014 11:08 am

Re: SSL compile error

Postby ESP_Faye » Tue Apr 21, 2015 4:00 pm

Hi,

Thanks for your interest in ESP8266 !

These are defined in cert.h and private_key.h in IOT_Demo.

doughboy
Posts: 63
Joined: Thu Mar 05, 2015 1:54 am

Re: SSL compile error

Postby doughboy » Tue Apr 21, 2015 11:53 pm

if you are using client api only, all you need is to define the variables in your user_main.c

unsigned char *default_certificate;
unsigned int default_certificate_len = 0;
unsigned char *default_private_key;
unsigned int default_private_key_len = 0;

if you are using server, you can generate your own self signed certificate and private key using openssl command line. You will also need xxd (this is in tools folder).
I use the following commands
openssl genrsa -out private.key 384
openssl req -new -x509 -key private.key -out server.cert -days 3650 -subj /CN=<yourname>
openssl enc -d -a -in private.key -out private.bin
openssl enc -d -a -in server.cert -out cert.bin
xxd -i private.bin > private.h
xxd -I cert.bin > cert.h
then change the variable names in the *.h files to the appropriate name.


BTW, I am trying to add SSL AT commands and it seems none of the SSL api works, at least when connecting to real world servers using real certificates like gmail.com, etc. even with 8k buffer.

Her Majesty
Posts: 305
Joined: Mon Oct 27, 2014 11:09 am

Re: SSL compile error

Postby Her Majesty » Wed Apr 22, 2015 10:53 am


doughboy
Posts: 63
Joined: Thu Mar 05, 2015 1:54 am

Re: SSL compile error

Postby doughboy » Wed Apr 22, 2015 11:20 am

Her Majesty wrote:Can this SSL demo help ? http://bbs.espressif.com/viewtopic.php?f=7&t=386


that is just a copy of the iot example, lol. no it won't help the original poster because it is not an AT command extension
have you actually tried using the ssl api?

ESP_Faye
Posts: 1638
Joined: Mon Oct 27, 2014 11:08 am

Re: SSL compile error

Postby ESP_Faye » Wed Apr 22, 2015 11:50 am

Hi, doughboy,

Thanks for your interest in ESP8266,

Please have a try with the demo code here http://bbs.espressif.com/viewtopic.php?f=21&t=389
Notice that there is a SSL patch http://bbs.espressif.com/viewtopic.php?f=5&t=382

In your case, you need to only change the IP , port and buffer size in user_check_ip , just as below

Code: Select all

       const char esp_server_ip[4] = {96, 114, 157, 81};

       os_memcpy(user_tcp_conn.proto.tcp->remote_ip, esp_server_ip, 4);

       user_tcp_conn.proto.tcp->remote_port = 465; // remote SSL port of tcp server
     
       user_tcp_conn.proto.tcp->local_port = espconn_port(); //local port of ESP8266

       espconn_regist_connectcb(&user_tcp_conn, user_tcp_connect_cb); // register connect callback
       espconn_regist_reconcb(&user_tcp_conn, user_tcp_recon_cb); // register reconnect callback as error handler

       espconn_secure_set_size(ESPCONN_CLIENT,5120); // set SSL buffer size, if your SSL packet larger than 2048
       espconn_secure_connect(&user_tcp_conn); // tcp SSL connect


Please have a try and let me know if your problem be solved or not ?

Who is online

Users browsing this forum: No registered users and 2 guests