Comments (6)
done :) cc4d1ac
give it a go ;)
BTW i'm looking into running axTLS async (no success yet)
from espasynctcp.
Fixed, thanks!
Oh you'll succeed, I am not worried. axTLS 2.0 brings TLS 1.2 moreover, so perfect timing. :)
from espasynctcp.
@marvinroger check this out: 110a997
client->connect(host, port, true) for SSL
from espasynctcp.
requires latest git of ESP8266 arduino
from espasynctcp.
#include <time.h>
extern "C" void system_set_os_print(uint8 onoff);
//call after wifi is up to set the time for ssl
bool initTime(){
time_t rawtime;
configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
uint8_t i = 0;
system_set_os_print(0);
while(time(&rawtime) == 0 && i++ < 100) delay(10);
system_set_os_print(1);
if(i==100){
Serial.println("Time Init Failed");
return false;
}
return true;
}
#include "include/ssl.h"
static AsyncClient * aClient = NULL;
const char *sslHost = "192.168.254.16";
const uint16_t sslPort = 443;
static void securePrintInfo(SSL *ssl){
if(!ssl){
return;
}
const char *common_name = ssl_get_cert_dn(ssl, SSL_X509_CERT_COMMON_NAME);
if (common_name) {
Serial.printf("COMMON NAME: %s\r\n", common_name);
}
Serial.printf("CIPHER: ");
switch (ssl_get_cipher_id(ssl)){
case SSL_AES128_SHA:
Serial.printf("AES128-SHA");
break;
case SSL_AES256_SHA:
Serial.printf("AES256-SHA");
break;
case SSL_RC4_128_SHA:
Serial.printf("RC4-SHA");
break;
case SSL_RC4_128_MD5:
Serial.printf("RC4-MD5");
break;
default:
Serial.printf("Unknown - %d", ssl_get_cipher_id(ssl));
break;
}
Serial.printf("\r\n");
int i;
const uint8_t *session_id = ssl_get_session_id(ssl);
int sess_id_size = ssl_get_session_id_size(ssl);
if (sess_id_size > 0){
Serial.printf("SESSION: ");
for (i = 0; i < sess_id_size; i++){
Serial.printf("%02x", session_id[i]);
}
Serial.printf("\r\n");
}
}
void runAsyncClient(){
if(aClient)//client already exists
return;
aClient = new AsyncClient();
if(!aClient)//could not allocate client
return;
aClient->onError([](void * arg, AsyncClient * client, int error){
Serial.println("Connect Error");
aClient = NULL;
delete client;
}, NULL);
aClient->onConnect([](void * arg, AsyncClient * client){
Serial.println("Connected");
securePrintInfo(client->getSSL());
aClient->onError(NULL, NULL);
client->onDisconnect([](void * arg, AsyncClient * c){
Serial.println("Disconnected");
aClient = NULL;
delete c;
}, NULL);
client->onData([](void * arg, AsyncClient * c, void * data, size_t len){
Serial.print("\r\nData: ");
Serial.println(len);
uint8_t * d = (uint8_t*)data;
for(size_t i=0; i<len;i++)
Serial.write(d[i]);
}, NULL);
//send the request
char m[256];
sprintf(m, "GET /test.htm HTTP/1.0\r\nHost: %s\r\n\r\n", sslHost);
int wrote = client->write(m, strlen(m));
Serial.printf("Sent: %u => %d\r\n", strlen(m), wrote);
}, NULL);
if(!aClient->connect(sslHost, sslPort, true)){
Serial.println("Connect Fail");
AsyncClient * client = aClient;
aClient = NULL;
delete client;
}
}
from espasynctcp.
Awesome! I will play with this as soon as I am back from vacation. Well done :)
from espasynctcp.
Related Issues (20)
- ESPAsyncTCP/src/tcp_axtls.h:44:10: fatal error: include/ssl.h: No such file or directory HOT 8
- AsyncTCP On Ethernet HOT 2
- [Question] Can this library be used with the "Adafruit MQTT Library" in the same project? HOT 2
- data in handleData() has trash on it and can crash the esp8266 when start with "S" HOT 1
- fatal error: include/ssl.h: No such file or directory HOT 3
- Sending more than 1072 bytes to client HOT 2
- ESPAsyncTCP/examples/ClientServer/Server/Server.ino HOT 2
- Sending multiple chunks of HTML as one (200, OK) respons HOT 2
- library is broken HOT 4
- Need example : How send a string to a client? HOT 2
- Can`t send more than 1072 bytes HOT 2
- AsyncPrinter _onConnect not working HOT 2
- Why are there no active releases available for download? HOT 4
- Ogo HOT 1
- Compilation error if defined ASYNC_TCP_SSL_ENABLED HOT 2
- Capturing client time-out by server
- Conversion to AsyncTCP issue
- Problems sending from the Client HOT 1
- Source of the ssl.h header file
- Does not work with IPV6. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espasynctcp.