2
0
Эх сурвалжийг харах

added console hooks support for ssl

ncannasse 6 жил өмнө
parent
commit
3720531512

+ 6 - 2
include/mbedtls/include/mbedtls/config.h

@@ -920,7 +920,9 @@
  *
  *
  * Enable functions that use the filesystem.
  * Enable functions that use the filesystem.
  */
  */
-#define MBEDTLS_FS_IO
+#ifndef __ORBIS__
+#	define MBEDTLS_FS_IO
+#endif
 
 
 /**
 /**
  * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
  * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
@@ -2535,7 +2537,9 @@
  *
  *
  * This module is used by the HAVEGE random number generator.
  * This module is used by the HAVEGE random number generator.
  */
  */
-#define MBEDTLS_TIMING_C
+#ifndef __ORBIS__
+#	define MBEDTLS_TIMING_C
+#endif
 
 
 /**
 /**
  * \def MBEDTLS_VERSION_C
  * \def MBEDTLS_VERSION_C

+ 14 - 0
libs/ssl/ssl.c

@@ -32,6 +32,10 @@ typedef int SOCKET;
 #include "mbedtls/x509_crt.h"
 #include "mbedtls/x509_crt.h"
 #include "mbedtls/ssl.h"
 #include "mbedtls/ssl.h"
 
 
+#ifdef HL_CONSOLE
+mbedtls_x509_crt *hl_init_cert_chain();
+#endif
+
 // Duplicate from socket.c
 // Duplicate from socket.c
 typedef struct _hl_socket {
 typedef struct _hl_socket {
 	SOCKET sock;
 	SOCKET sock;
@@ -294,6 +298,9 @@ DEFINE_PRIM(_VOID, conf_set_cert, TCONF TCERT TPKEY);
 DEFINE_PRIM(_VOID, conf_set_servername_callback, TCONF _FUN(_OBJ(TCERT TPKEY), _BYTES));
 DEFINE_PRIM(_VOID, conf_set_servername_callback, TCONF _FUN(_OBJ(TCERT TPKEY), _BYTES));
 
 
 HL_PRIM hl_ssl_cert *HL_NAME(cert_load_file)(vbyte *file) {
 HL_PRIM hl_ssl_cert *HL_NAME(cert_load_file)(vbyte *file) {
+#ifdef HL_CONSOLE
+	return NULL;
+#else
 	int r;
 	int r;
 	hl_ssl_cert *cert;
 	hl_ssl_cert *cert;
 	mbedtls_x509_crt *x = (mbedtls_x509_crt*)malloc(sizeof(mbedtls_x509_crt));
 	mbedtls_x509_crt *x = (mbedtls_x509_crt*)malloc(sizeof(mbedtls_x509_crt));
@@ -308,9 +315,13 @@ HL_PRIM hl_ssl_cert *HL_NAME(cert_load_file)(vbyte *file) {
 	cert->c = x;
 	cert->c = x;
 	cert->finalize = cert_finalize;
 	cert->finalize = cert_finalize;
 	return cert;
 	return cert;
+#endif
 }
 }
 
 
 HL_PRIM hl_ssl_cert *HL_NAME(cert_load_path)(vbyte *path) {
 HL_PRIM hl_ssl_cert *HL_NAME(cert_load_path)(vbyte *path) {
+#ifdef HL_CONSOLE
+	return NULL;
+#else
 	int r;
 	int r;
 	hl_ssl_cert *cert;
 	hl_ssl_cert *cert;
 	mbedtls_x509_crt *x = (mbedtls_x509_crt*)malloc(sizeof(mbedtls_x509_crt));
 	mbedtls_x509_crt *x = (mbedtls_x509_crt*)malloc(sizeof(mbedtls_x509_crt));
@@ -325,6 +336,7 @@ HL_PRIM hl_ssl_cert *HL_NAME(cert_load_path)(vbyte *path) {
 	cert->c = x;
 	cert->c = x;
 	cert->finalize = cert_finalize;
 	cert->finalize = cert_finalize;
 	return cert;
 	return cert;
+#endif
 }
 }
 
 
 HL_PRIM hl_ssl_cert *HL_NAME(cert_load_defaults)() {
 HL_PRIM hl_ssl_cert *HL_NAME(cert_load_defaults)() {
@@ -379,6 +391,8 @@ HL_PRIM hl_ssl_cert *HL_NAME(cert_load_defaults)() {
 		}
 		}
 	}
 	}
 	CFRelease(keychain);
 	CFRelease(keychain);
+#elif defined(HL_CONSOLE)
+	chain = hl_init_cert_chain();
 #endif
 #endif
 	if (chain != NULL) {
 	if (chain != NULL) {
 		v = (hl_ssl_cert*)hl_gc_alloc_finalizer(sizeof(hl_ssl_cert));
 		v = (hl_ssl_cert*)hl_gc_alloc_finalizer(sizeof(hl_ssl_cert));