|
@@ -64,7 +64,7 @@ uint16_t receivedBufLen = 0;
|
|
|
|
|
|
#define MAX_POST_REQ_LEN 256
|
|
|
char post_req_data[MAX_POST_REQ_LEN];
|
|
|
-uint32_t post_data_count;
|
|
|
+uint32_t post_data_count = 0;
|
|
|
uint32_t log_post_reqn;
|
|
|
|
|
|
/* Logout timeout, 30 minutes */
|
|
@@ -2846,7 +2846,7 @@ mbedtls_ssl_config conf;
|
|
|
mbedtls_x509_crt srvcert;
|
|
|
mbedtls_pk_context pkey;
|
|
|
|
|
|
-char CookieBuf[50];
|
|
|
+char CookieBuf[51];
|
|
|
char *CookiePtr = NULL;
|
|
|
char name[MAX_WEB_COOKIE_LEN];
|
|
|
char id[MAX_WEB_COOKIE_LEN];
|
|
@@ -2857,23 +2857,36 @@ struct fs_file file = {0, 0};
|
|
|
//
|
|
|
void Cockie(void)
|
|
|
{
|
|
|
+ char* endPtr;
|
|
|
+ uint32_t len;
|
|
|
receiveBuf[receivedBufLen] = '\0';
|
|
|
- // printf("receive %s \r\n", receiveBuf);
|
|
|
+ printf("receive %s \r\n", receiveBuf);
|
|
|
// Get cookie "uname" value
|
|
|
+ memset(CookieBuf, 0, sizeof(CookieBuf));
|
|
|
CookiePtr = strstr(receiveBuf, "uname=");
|
|
|
- strncpy(CookieBuf, CookiePtr, 50);
|
|
|
- //printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
|
+ endPtr = strstr(CookiePtr, "\r");
|
|
|
+ len = (endPtr - CookiePtr)+2;
|
|
|
+ if(len < 50)
|
|
|
+ strncpy(CookieBuf, CookiePtr,len);
|
|
|
+ else
|
|
|
+ strncpy(CookieBuf, CookiePtr, 50);
|
|
|
+ /// printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
|
memset(name, 0, MAX_WEB_COOKIE_LEN);
|
|
|
GetCookieValue(CookieBuf, "uname=", name, &nameLen);
|
|
|
- //printf("********CookieBuf2= %s\r\n", CookieBuf);
|
|
|
- //printf("********uname= %s\r\n", name);
|
|
|
+// printf("********CookieBuf2= %s\r\n", CookieBuf);
|
|
|
+ // printf("********uname= %s\r\n", name);
|
|
|
|
|
|
+ memset(CookieBuf, 0, sizeof(CookieBuf));
|
|
|
// Get cookie "id" value
|
|
|
- CookiePtr = strstr(receiveBuf, "id=");
|
|
|
- strncpy(CookieBuf, CookiePtr, 50);
|
|
|
- //printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
|
+ CookiePtr = strstr(receiveBuf, " id=");
|
|
|
+ if(len < 50)
|
|
|
+ strncpy(CookieBuf, CookiePtr,len);
|
|
|
+ else
|
|
|
+ strncpy(CookieBuf, CookiePtr, 50);
|
|
|
+// printf("********CookieBuf1= %s\r\n", CookieBuf);
|
|
|
memset(id, 0, MAX_WEB_COOKIE_LEN);
|
|
|
GetCookieValue(CookieBuf, "id=", id, &idLen);
|
|
|
+ // printf("********ID= %s\r\n", id);
|
|
|
}
|
|
|
|
|
|
//
|
|
@@ -2991,7 +3004,7 @@ void ssl_server(void *pvParameters)
|
|
|
}
|
|
|
else {
|
|
|
//mbedtls_ssl_init(&ssl);
|
|
|
- mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, NULL );
|
|
|
+ mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, NULL );//mbedtls_net_recv
|
|
|
mbedtls_printf( " ok\r\n" );
|
|
|
|
|
|
ssl_state = SSL_HANDSHAKE;
|
|
@@ -3022,7 +3035,7 @@ void ssl_server(void *pvParameters)
|
|
|
break;
|
|
|
|
|
|
case SSL_READ :
|
|
|
-
|
|
|
+ printf("SSL_READ\r\n");
|
|
|
if (SSL_ReadRoutine(&ssl, (unsigned char*)receiveBuf) <= 0)
|
|
|
ssl_state = SSL_ERROR;
|
|
|
else
|
|
@@ -3030,7 +3043,7 @@ void ssl_server(void *pvParameters)
|
|
|
break;
|
|
|
|
|
|
case SSL_PROCESSING :
|
|
|
-
|
|
|
+ printf("SSL_PROCESSING\r\n");
|
|
|
sendPtr = SSL_ProcessingRoutine(&sendBufLoadLen);
|
|
|
if (sendPtr)
|
|
|
ssl_state = SSL_WRITE;
|
|
@@ -3040,11 +3053,14 @@ void ssl_server(void *pvParameters)
|
|
|
break;
|
|
|
|
|
|
case SSL_WRITE :
|
|
|
- if (SSL_WriteRoutine(&ssl, sendPtr, sendBufLoadLen) == SSL_WRITE_OK)
|
|
|
+ printf("SSL_WRITE\r\n");
|
|
|
+ SSL_WriteRoutine(&ssl, sendPtr, sendBufLoadLen);
|
|
|
+ // if (SSL_WriteRoutine(&ssl, sendPtr, sendBufLoadLen) == SSL_WRITE_OK)
|
|
|
ssl_state = SSL_CLOSE;
|
|
|
break;
|
|
|
|
|
|
case SSL_CLOSE :
|
|
|
+ printf("SSL_CLOSE\r\n");
|
|
|
mbedtls_ssl_close_notify(&ssl);
|
|
|
mbedtls_net_free(&client_fd);
|
|
|
//mbedtls_ssl_free( &ssl );
|
|
@@ -3052,6 +3068,7 @@ void ssl_server(void *pvParameters)
|
|
|
break;
|
|
|
|
|
|
case SSL_ERROR :
|
|
|
+ printf("SSL_ERROR\r\n");
|
|
|
//mbedtls_net_free(&client_fd);
|
|
|
//mbedtls_ssl_free( &ssl );
|
|
|
mbedtls_net_free(&client_fd);
|
|
@@ -3059,7 +3076,7 @@ void ssl_server(void *pvParameters)
|
|
|
break;
|
|
|
|
|
|
case SSL_CRITICAL_ERROR:
|
|
|
-
|
|
|
+ printf("SSL_CRITICAL_ERROR\r\n");
|
|
|
mbedtls_x509_crt_free( &srvcert );
|
|
|
mbedtls_pk_free( &pkey );
|
|
|
mbedtls_ssl_free( &ssl );
|
|
@@ -3123,7 +3140,7 @@ int SSL_ReadRoutine(mbedtls_ssl_context *ssl, unsigned char* recvBuf)
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- mbedtls_printf( " mbedtls_ssl_read returned -0x%x\r\n", -ret );
|
|
|
+ mbedtls_printf( "mbedtls_ssl_read returned -0x%x\r\n", -ret );
|
|
|
break;
|
|
|
}
|
|
|
return ret;
|
|
@@ -3132,9 +3149,9 @@ int SSL_ReadRoutine(mbedtls_ssl_context *ssl, unsigned char* recvBuf)
|
|
|
receivedBufLen = ret;
|
|
|
//mbedtls_printf( " %d bytes read\r\n%s", len, (char *) receiveBuf );
|
|
|
//mbedtls_printf( " %d bytes read\r\n", receivedBufLen);
|
|
|
-
|
|
|
- //printf(receiveBuf);
|
|
|
- //printf("\r\n");
|
|
|
+ /* printf("\r\n\r\n");
|
|
|
+ printf(receiveBuf);
|
|
|
+ printf("\r\n");*/
|
|
|
|
|
|
} while(0);
|
|
|
}
|
|
@@ -3148,10 +3165,12 @@ SSL_SERVER_STATE SSL_WriteRoutine(mbedtls_ssl_context *ssl, char *data, int data
|
|
|
//
|
|
|
char* SSL_ProcessingRoutine(uint16_t* sendLen)
|
|
|
{
|
|
|
+ /**sendLen = strlen(HTTP_RESPONSE);
|
|
|
+ return HTTP_RESPONSE;*/
|
|
|
Cockie();
|
|
|
- getAuthenticatedState();
|
|
|
-
|
|
|
- if ( Authenticated == false && sSettings.sRADIUS.Auth_enable == false)
|
|
|
+ getAuthenticatedState();
|
|
|
+
|
|
|
+ if ( Authenticated == false && sSettings.sRADIUS.Auth_enable == false)
|
|
|
{
|
|
|
HTTP_LOGIN(sendBuf, sendLen);
|
|
|
return sendBuf;
|
|
@@ -3160,10 +3179,11 @@ char* SSL_ProcessingRoutine(uint16_t* sendLen)
|
|
|
{
|
|
|
return AuthenticatedFalseRoutine(sendLen);
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
return AuthenticatedTrueRoutine(sendLen);
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//
|
|
@@ -3221,6 +3241,7 @@ char* AuthenticatedFalseRoutine(uint16_t* sendLen)
|
|
|
strncat(post_req_data, offset, post_data_count);
|
|
|
if (HTTP_ConfirmWebPwd(post_req_data, sendBuf, strlen(post_req_data), sendLen) == SEND_REQUIRED_YES)
|
|
|
{
|
|
|
+ post_data_count = 0;
|
|
|
return sendBuf;
|
|
|
}
|
|
|
else
|
|
@@ -3231,9 +3252,10 @@ char* AuthenticatedFalseRoutine(uint16_t* sendLen)
|
|
|
fs_open("/login.html", &file);
|
|
|
ssl_sendframes(&ssl, file.data, file.len);*/
|
|
|
//ssl_sendframes(&ssl, sendBuf, sendBufLoadLen);
|
|
|
+ post_data_count = 0;
|
|
|
return sendBuf;
|
|
|
}
|
|
|
- post_data_count = 0;
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|