-->
Page 1 of 2

Attempt to connect to webserver via HTTPS

PostPosted: Wed Feb 25, 2015 8:26 pm
by rith87
I'm adapting the sample code at http://www.electrodragon.com/w/ESP8266_IoT to establish an HTTPS connection. My first stab at it is as follows:

This was in the CLIENT_SSL_ENABLE #ifdef in the original sample code. I assume that these variables are to store the certificates/public keys from the server? (but the variable name says *private_key*, I guess I'll dig a little deeper)

Code: Select all#ifdef ENABLE_SSL_SUPPORT
unsigned char *default_certificate;
unsigned int default_certificate_len = 0;
unsigned char *default_private_key;
unsigned int default_private_key_len = 0;
#endif


And then I replaced all the espconn* calls with the secure versions (my ESP8266 can connect to basic HTTP servers):
Code: Select all    #ifdef ENABLE_SSL_SUPPORT
    espconn_secure_connect(pCon);
    #else
    espconn_connect(pCon);
    #endif
...
    #ifdef ENABLE_SSL_SUPPORT
    espconn_secure_sent(pespconn, payload, strlen(payload));
    #else
    espconn_sent(pespconn, payload, strlen(payload));
    #endif
...
    #ifdef ENABLE_SSL_SUPPORT
    espconn_secure_disconnect(conn);
    #else
    espconn_disconnect(conn);
    #endif


Unfortunately, I seem to be hitting a crash:
Code: Select allStart espconn_connect to <HTTPS server IP> 443

 ets Jan  8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 24872, room 16
tail 8
chksum 0x5b
load 0x3ffe8000, len 2652, room 0
tail 12
chksum 0x8d
ho 0 tail 12 room 4
load 0x3ffe8a60, len 7220, room 12
tail 8
chksum 0x5a
csum 0x5a


So I guess I had a few questions:
1. How is everyone else connecting to HTTPS servers? Any samples? What is the problem with my approach?
2. How do folks here debug crashes? printf debugging?

Re: Attempt to connect to webserver via HTTPS

PostPosted: Thu Feb 26, 2015 1:44 am
by rith87
Another data point, I'm trying to connect to https://www.hurl.it/; the first espconn_connect() call returns 0 but the callback upon connection is never called. Subsequent espconn_connect() calls return -15, which means that the connection already exists. FWIW, I'm connecting to the webserver via its IP address, so it is 107.20.153.137:443 for hurl.it.

Re: Attempt to connect to webserver via HTTPS

PostPosted: Fri Feb 27, 2015 1:55 am
by rith87
Not sure who's following this thread but I've managed to get a 200 response from https://spritesmods.com/ after making the changes suggested in http://bbs.espressif.com/viewtopic.php? ... ecure+http. It seems like the ESP8266 does not like super large SSL certificates.

Re: Attempt to connect to webserver via HTTPS

PostPosted: Fri Feb 27, 2015 3:16 am
by alonewolfx2
How about small ssl certs?