浏览代码

add req cert in web

balbekova 7 年之前
父节点
当前提交
7d152f0eda
共有 2 个文件被更改,包括 11 次插入9 次删除
  1. 10 8
      modules/HTTP_Server/http_server.c
  2. 1 1
      user/init_task.c

+ 10 - 8
modules/HTTP_Server/http_server.c

@@ -2847,6 +2847,8 @@ void HTTPS_Init()
 #include <stdlib.h>
 #include <string.h>
 
+extern unsigned char req_cert[];
+
 char HTTP_RESPONSE[] = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n \
                        <h2>mbed TLS Test Server</h2>\r\n \
                        <p>Successful connection using: %s</p>\r\n";
@@ -3029,7 +3031,6 @@ void ssl_server(void *pvParameters)
     case SSL_HANDSHAKE :
       
       mbedtls_printf( "  . Performing the SSL/TLS handshake..." );
-      handshakeTime = xTaskGetTickCount();
       while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 )
       {
         if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
@@ -3044,7 +3045,6 @@ void ssl_server(void *pvParameters)
         ssl_state = SSL_ERROR;
       else {
         mbedtls_printf( " ok\r\n" );
-        printf("HANDSHAKE_TIME: %d ms\r\n", xTaskGetTickCount() - handshakeTime);
         ssl_state = SSL_READ;
       }
       
@@ -3484,16 +3484,18 @@ char* AuthenticatedTrueRoutine(uint16_t* sendLen)
     } 
     else if (strncmp(receiveBuf, "GET /getcert.cgi", 16) == 0)
     {
-    	/* Send HTTP header first (Safari needs it) */
+    	// Send HTTP header first (Safari needs it)
 
 		  strcpy(sendBuf, HTTP_200_OK);
-		  *sendLen = strlen(sendBuf);
-		  SSL_WriteRoutine(&ssl, sendBuf, *sendLen);
+		  /**sendLen = strlen(sendBuf);
+		  SSL_WriteRoutine(&ssl, sendBuf, *sendLen);*/
 
-		//  SSL_Test();
+		  SSL_Test();
 
-		  *sendLen = strlen(req_cert);
-		  return req_cert;
+
+		  strncpy(sendBuf, req_cert, strlen(req_cert));
+		  *sendLen = strlen(sendBuf);
+		  return sendBuf;
     }
     else if (strncmp(receiveBuf, "POST /srv_crt_upload.cgi", 24) == 0)
     {

+ 1 - 1
user/init_task.c

@@ -140,7 +140,7 @@ void InitTask(void *params)
 
 	   HTTPS_Init();
 //#define SSL_TASK_PRIO   ( configMAX_PRIORITIES - 3 )
-	   xTaskCreate(ssl_server, "SSL", 10*configMINIMAL_STACK_SIZE, NULL, SSL_TASK_PRIO, NULL);
+	   xTaskCreate(ssl_server, "SSL", 20*configMINIMAL_STACK_SIZE, NULL, SSL_TASK_PRIO, NULL);
 #endif
 	   // UDP for net settings 
 	   if(strncmp(sSettings.sFlags.testState, "T2OK", 4)){