Set espconn's secure buffer size once at initialization (#1466)

Fixes #1457
This commit is contained in:
Yury Popov 2016-09-04 23:45:46 +03:00 committed by Marcel Stör
parent eddda24a6f
commit be263dacde
6 changed files with 9 additions and 8 deletions

View File

@ -477,7 +477,6 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
if ( req->secure ) if ( req->secure )
{ {
espconn_secure_set_size( ESPCONN_CLIENT, 5120 ); /* set SSL buffer size */
espconn_secure_connect( conn ); espconn_secure_connect( conn );
} }
else else

View File

@ -60,6 +60,10 @@ extern void luaL_assertfail(const char *file, int line, const char *message);
#define NO_INTR_CODE inline #define NO_INTR_CODE inline
#endif #endif
// SSL buffer size used only for espconn-layer secure connections.
// See https://github.com/nodemcu/nodemcu-firmware/issues/1457 for conversation details.
#define SSL_BUFFER_SIZE 5120
//#define CLIENT_SSL_ENABLE //#define CLIENT_SSL_ENABLE
//#define MD2_ENABLE //#define MD2_ENABLE
#define SHA2_ENABLE #define SHA2_ENABLE

View File

@ -1618,9 +1618,6 @@ static const LUA_REG_TYPE mqtt_map[] = {
int luaopen_mqtt( lua_State *L ) int luaopen_mqtt( lua_State *L )
{ {
luaL_rometatable(L, "mqtt.socket", (void *)mqtt_socket_map); // create metatable for mqtt.socket luaL_rometatable(L, "mqtt.socket", (void *)mqtt_socket_map); // create metatable for mqtt.socket
#ifdef CLIENT_SSL_ENABLE
espconn_secure_set_size(ESPCONN_CLIENT, 4096);
#endif
return 0; return 0;
} }

View File

@ -577,7 +577,6 @@ static void socket_connect(struct espconn *pesp_conn)
{ {
#ifdef CLIENT_SSL_ENABLE #ifdef CLIENT_SSL_ENABLE
if(nud->secure){ if(nud->secure){
espconn_secure_set_size(ESPCONN_CLIENT, 5120); /* set SSL buffer size */
espconn_secure_connect(pesp_conn); espconn_secure_connect(pesp_conn);
} }
else else

View File

@ -22,6 +22,7 @@
#include "driver/uart.h" #include "driver/uart.h"
#include "task/task.h" #include "task/task.h"
#include "mem.h" #include "mem.h"
#include "espconn.h"
#ifdef LUA_USE_MODULES_RTCTIME #ifdef LUA_USE_MODULES_RTCTIME
#include "rtc/rtctime.h" #include "rtc/rtctime.h"
@ -98,6 +99,10 @@ void nodemcu_init(void)
} }
#endif // defined(FLASH_SAFE_API) #endif // defined(FLASH_SAFE_API)
#if defined ( CLIENT_SSL_ENABLE ) && defined ( SSL_BUFFER_SIZE )
espconn_secure_set_size(ESPCONN_CLIENT, SSL_BUFFER_SIZE);
#endif
#if defined ( BUILD_SPIFFS ) #if defined ( BUILD_SPIFFS )
if (!fs_mount()) { if (!fs_mount()) {
// Failed to mount -- try reformat // Failed to mount -- try reformat

View File

@ -47,8 +47,6 @@
#define PORT_INSECURE 80 #define PORT_INSECURE 80
#define PORT_MAX_VALUE 65535 #define PORT_MAX_VALUE 65535
#define SSL_BUFFER_SIZE 5120
// TODO: user agent configurable // TODO: user agent configurable
#define WS_INIT_HEADERS "GET %s HTTP/1.1\r\n"\ #define WS_INIT_HEADERS "GET %s HTTP/1.1\r\n"\
"Host: %s:%d\r\n"\ "Host: %s:%d\r\n"\
@ -656,7 +654,6 @@ static void dns_callback(const char *hostname, ip_addr_t *addr, void *arg) {
if (ws->isSecure) { if (ws->isSecure) {
NODE_DBG("secure connecting \n"); NODE_DBG("secure connecting \n");
espconn_secure_set_size(ESPCONN_CLIENT, SSL_BUFFER_SIZE);
espconn_secure_connect(conn); espconn_secure_connect(conn);
} }
else { else {