diff --git a/.gitignore b/.gitignore
index 8b3c1c1..654dd38 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@ xgconsole/Win32/
 xgconsole/edit.txt
 xgconsole/release/
 xgconsole/readline-7.0/
+/openssl-win-x64
+/xgconsole/security
diff --git a/xgconsole/include/rhdbdriver.h b/xgconsole/include/rhdbdriver.h
index dd842ce..698042d 100644
--- a/xgconsole/include/rhdbdriver.h
+++ b/xgconsole/include/rhdbdriver.h
@@ -183,6 +183,8 @@ typedef struct RhConnect{
 	jmp_buf	mark;
 #ifdef MY_DLL_EXPORTS
 	BOOL		use_ssl;								/*F:δʹ�ð�ȫ�׽���;T:ʹ�ð�ȫ�׽���*/
+	BOOL        tongsuo;
+	SSL         *ssl;
 	BOOL		is_asyn;
 	BOOL		auto_commit;
     #ifdef WIN32
@@ -269,7 +271,8 @@ MY_DLL_API RhConnect*	__stdcall	connectDB(const char *ip_str,short int port,
 MY_DLL_API RhConnect*	__stdcall	ssl_connectDB(const char *ip_str,short int port,
 										  const char *db_name,const char *usr_name,
 										  const char *pass_word);
-MY_DLL_API RhConnect*	__stdcall	login(const char *ip_str,
+MY_DLL_API RhConnect*	__stdcall	login(const char *ssl_str,
+										  const char *ip_str,
 										  short int  port,
 										  const char *db_name,
 										  const char *usr_name,
diff --git a/xgconsole/include/ssl.h b/xgconsole/include/ssl.h
index c44bef0..c37b6ca 100644
--- a/xgconsole/include/ssl.h
+++ b/xgconsole/include/ssl.h
@@ -2,6 +2,8 @@
 #define __OK_SSL_H
 
 #include "Turing.h"		/* interface definitions */
+#include "openssl/ssl.h"
+#include "openssl/err.h"
 
 typedef struct TuringData
 {
diff --git a/xgconsole/src/console.cpp b/xgconsole/src/console.cpp
index 2085c10..8e4a636 100644
--- a/xgconsole/src/console.cpp
+++ b/xgconsole/src/console.cpp
@@ -519,7 +519,8 @@ get_conn_info:
 		p_conn = NULL;
 	}
 	else { 
-		p_conn = login(ip_str, port, db_name, user_name, password, encry_str, CHAR_SET, NULL, NULL, 0, is_auto_commit, false, false);
+		bool is_ssl = !strcmp(ssl_str, "ssl") || !strcmp(ssl_str, "SSL") || !strcmp(ssl_str, "tls") || !strcmp(ssl_str, "TLS") || !strcmp(ssl_str, "gmssl") || !strcmp(ssl_str, "GMSSL");
+		p_conn = login(ssl_str, ip_str, port, db_name, user_name, password, encry_str, CHAR_SET, NULL, NULL, 0, is_auto_commit, is_ssl, false);
  	}
 		
 	//p_conn = login(ip_str, port, db_name, user_name, password, encry_str, "UTF8", NULL, NULL, 0, auto_commit, false, true);
@@ -1944,7 +1945,7 @@ get_conn_info:
 				RhResult *var_res = wq_exe(p_conn, "SELECT * FROM DUAL", is_auto_commit);
 				if (!var_res)
 					goto reconnect;
-				sqlldr(p_conn, line_varray + hdspace);
+				//sqlldr(p_conn, line_varray + hdspace);
 				i = 0;
 				continue;
 			}
@@ -3205,7 +3206,7 @@ get_conn_info:
 				{
 					sprintf_s(cmd_buff, "sqlldr table=%s.%s datafile=%s ft='|' rt=X'0a' log = ./load.log errlog=./loaderr.log", sc_name, tab_name, filepath);
 				}
-				sqlldr(p_conn, cmd_buff);
+				//sqlldr(p_conn, cmd_buff);
 
 				continue;
 
@@ -5899,11 +5900,11 @@ reconnect:
 
 bool auto_reconnect()
 {
-	if (!strcmp(ssl_str, "ssl") || !strcmp(ssl_str, "SSL"))
+	if (p_conn->use_ssl)
 	{
 		if (!strcmp(ssl_str, "SSL"))
 			b_pause = false;//不用ESC和Q
-		p_conn = login(ip_str, port, db_name, user_name, password, encry_str, CHAR_SET, NULL, NULL, 0, true, true, false);
+		p_conn = login(ssl_str, ip_str, port, db_name, user_name, password, encry_str, CHAR_SET, NULL, NULL, 0, true, true, false);
 		if (p_conn)
 		{
 			printf("SSL Connect ok.\r\n");
@@ -5924,7 +5925,7 @@ bool auto_reconnect()
 	}
 	else
 	{
-		p_conn = login(ip_str, port, db_name, user_name, password, encry_str, CHAR_SET, NULL, NULL, 0, true, false, false);
+		p_conn = login(ssl_str, ip_str, port, db_name, user_name, password, encry_str, CHAR_SET, NULL, NULL, 0, true, false, false);
 		if (p_conn)
 		{
 			printf("Connect ok.\r\n");
diff --git a/xgconsole/src/console_ff.cpp b/xgconsole/src/console_ff.cpp
index 5542747..fae3a45 100644
--- a/xgconsole/src/console_ff.cpp
+++ b/xgconsole/src/console_ff.cpp
@@ -402,7 +402,7 @@ static void gettime()
 
 void debug_show_thd(void *para)
 {
-	aux_conn = login(ip_str, port, db_name, user_name, password, encry_str, NULL, NULL, NULL, 0, false, false, false);
+	aux_conn = login(ssl_str,ip_str, port, db_name, user_name, password, encry_str, NULL, NULL, NULL, 0, false, false, false);
 	//aux_conn = login(ip_str, port, db_name, user_name, password, encry_str, "UTF8", NULL, NULL, 0, true, false, true);
 	 // 2021-04-29 linux
 	if (!aux_conn)
diff --git a/xgconsole/src/rhdbdriver.c b/xgconsole/src/rhdbdriver.c
index 1736e01..8eb1849 100644
--- a/xgconsole/src/rhdbdriver.c
+++ b/xgconsole/src/rhdbdriver.c
@@ -17,6 +17,8 @@
 
 
 
+static SSL_CTX *ssl_ctx; // TLS 服务端全局上下文
+static SSL_CTX *gmssl_ctx; // GMSSL 服务端全局上下文
 #define		sema				HANDLE
 #define		INFINITE            0xFFFFFFFF
 #define		create_sema()		CreateSemaphore(NULL,0,2000000000,NULL)
@@ -214,7 +216,8 @@ void insert_7(char *auth_str)
 	}
 }
 
-MY_DLL_API RhConnect*	__stdcall	login(const char *ip_str,
+MY_DLL_API RhConnect*	__stdcall	login(const char *ssl_str,
+										  const char *ip_str,
 										  short int  port,
 										  const char *db_name,
 										  const char *usr_name,
@@ -302,86 +305,269 @@ MY_DLL_API RhConnect*	__stdcall	login(const char *ip_str,
 		if(is_ssl)
 		{
     #ifdef WIN32
-			p_conn->use_ssl = TRUE;
-			/*发送"~ssl~"*/
-			send(sock,"~ssl~",5,0);
-			/*接收公钥*/
-			my_recv(p_conn,(char*)p_conn->public_key,32);
-			my_recv(p_conn,(char*)p_conn->trail_key,32);
-
-			/*生成32字节随机数用作流加密器的键*/
-			for(j=0;j<8;j++)
-				key[j] = spPseudoRand(0, MAX_DIGIT);
-
-			p_ch = (char*)pass_word;
-			p_ch1 = (char*)key;
-			for(j=0;j<32;j++)
-			{	/*将password 异或进key*/
-				*p_ch1 ++ ^=  *p_ch++;
-				if(! *p_ch)
-					p_ch = (char*)pass_word;
+			SSL_library_init();
+			SSL_load_error_strings();
+			if (!ssl_ctx) {
+				SSL_load_error_strings();
+				ssl_ctx = SSL_CTX_new(TLS_client_method());
+				if (SSL_CTX_load_verify_locations(ssl_ctx, "ssl/cacert.pem", NULL) != 1) {
+					printf("Load CA certificate file failed");
+					return NULL;
+				}
+				// CRL 文件应为可选，若未加载成功，不开启 CRL 验证
+				X509_STORE* x509_store = SSL_CTX_get_cert_store(ssl_ctx);
+				if (X509_STORE_load_locations(x509_store, "ssl/crl.pem", NULL) != 1) {
+					printf("Load CA certificate revocation list file failed");
+				}
+				else {
+					//开启驱动证书验证
+					X509_VERIFY_PARAM* param = X509_VERIFY_PARAM_new();
+					X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK_ALL);
+					SSL_CTX_set1_param(ssl_ctx, param);
+					X509_VERIFY_PARAM_free(param);
+				}
+				if (SSL_CTX_use_certificate_file(ssl_ctx, "ssl/driver.crt", SSL_FILETYPE_PEM) != 1) {
+					printf("Load driver certificate file failed");
+					return NULL;
+				}
+				if (SSL_CTX_use_PrivateKey_file(ssl_ctx, "ssl/driver.key", SSL_FILETYPE_PEM) != 1) {
+					printf("Load driver private key file failed");
+					return NULL;
+				}
+				// 开启对端(服务端)证书验证
+				SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL);
 			}
-			key[7] &= ~HIBITMASK;
-			memcpy(auth_str,key,32);	
-			strcpy(auth_str+32,"login database = ");
-			strcat(auth_str+32,db_name);
-			strcat(auth_str+32," user='");
-			strcat(auth_str+32,usr_name);
-			strcat(auth_str+32,"' password='");
-			strcat(auth_str+32,pass_word);
-			strcat(auth_str+32,"'");
-			if(encry_str != NULL)
-			{
-				strcat(auth_str+32," encryptor = '");
-				strcat(auth_str+32,encry_str);
-				strcat(auth_str+32,"'");
+			if (!gmssl_ctx) {
+				gmssl_ctx = SSL_CTX_new(NTLS_client_method());
+				SSL_CTX_enable_ntls(gmssl_ctx);
+				if (SSL_CTX_load_verify_locations(gmssl_ctx, "gmssl/cacert.pem", NULL) != 1) {
+					printf("Load CA certificate chain file failed");
+					return NULL;
+				}
+				// CRL 文件应为可选，若未加载成功，不开启 CRL 验证
+				X509_STORE* x509_store = SSL_CTX_get_cert_store(gmssl_ctx);
+				if (X509_STORE_load_locations(x509_store, "gmssl/crl.pem", NULL) != 1) {
+					printf("Load CA certificate revocation list chain file failed");
+				}
+				else {
+					//开启驱动证书验证
+					X509_VERIFY_PARAM* param = X509_VERIFY_PARAM_new();
+					X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK_ALL);
+					SSL_CTX_set1_param(gmssl_ctx, param);
+					X509_VERIFY_PARAM_free(param);
+				}
+				//可选：指定客户端支持的国标密码套件，具体列表参见铜锁头文件 openssl/ntls.h
+				//if (SSL_CTX_set_cipher_list(gmssl_ctx, "ECDHE-SM2-SM4-CBC-SM3") != 1) {
+				//	printf("Set cipher suite failed");
+				//	return NULL;
+				//}
+				if (SSL_CTX_use_sign_certificate_file(gmssl_ctx, "gmssl/driver-sign.crt", SSL_FILETYPE_PEM) != 1) {
+					printf("Load driver signature certificate file failed");
+					return NULL;
+				}
+				if (SSL_CTX_use_sign_PrivateKey_file(gmssl_ctx, "gmssl/driver-sign.key", SSL_FILETYPE_PEM) != 1) {
+					printf("Load driver signature private key file failed");
+					return NULL;
+				}
+				if (SSL_CTX_use_enc_certificate_file(gmssl_ctx, "gmssl/driver-enc.crt", SSL_FILETYPE_PEM) != 1) {
+					printf("Load driver encrypt certificate file failed");
+					return NULL;
+				}
+				if (SSL_CTX_use_enc_PrivateKey_file(gmssl_ctx, "gmssl/driver-enc.key", SSL_FILETYPE_PEM) != 1) {
+					printf("Load driver encrypt private key file failed");
+					return NULL;
+				}
+				// 开启对端(服务端)证书验证
+				SSL_CTX_set_verify(gmssl_ctx, SSL_VERIFY_PEER, NULL);
 			}
+			p_conn->use_ssl = TRUE;
 
-			if(char_set != NULL)
-			{
-				strcat(auth_str+32," char_set = '");
-				strcat(auth_str+32,char_set);
+			int isSSL  = !strcmp(ssl_str, "ssl") || !strcmp(ssl_str, "SSL");
+			int isTLS  = !strcmp(ssl_str, "tls") || !strcmp(ssl_str, "TLS");
+			int isGMSSL = !strcmp(ssl_str, "gmssl") || !strcmp(ssl_str, "GMSSL");
+			if (isSSL) {
+				p_conn->tongsuo = FALSE;
+				/*发送"~ssl~"*/
+				send(sock,"~ssl~",5,0);
+				/*接收公钥*/
+				my_recv(p_conn,(char*)p_conn->public_key,32);
+				my_recv(p_conn,(char*)p_conn->trail_key,32);
+
+				/*生成32字节随机数用作流加密器的键*/
+				for(j=0;j<8;j++)
+					key[j] = spPseudoRand(0, MAX_DIGIT);
+
+				p_ch = (char*)pass_word;
+				p_ch1 = (char*)key;
+				for(j=0;j<32;j++)
+				{	/*将password 异或进key*/
+					*p_ch1 ++ ^=  *p_ch++;
+					if(! *p_ch)
+						p_ch = (char*)pass_word;
+				}
+				key[7] &= ~HIBITMASK;
+				memcpy(auth_str,key,32);	
+				strcpy(auth_str+32,"login database = ");
+				strcat(auth_str+32,db_name);
+				strcat(auth_str+32," user='");
+				strcat(auth_str+32,usr_name);
+				strcat(auth_str+32,"' password='");
+				strcat(auth_str+32,pass_word);
 				strcat(auth_str+32,"'");
-			}
+				if(encry_str != NULL)
+				{
+					strcat(auth_str+32," encryptor = '");
+					strcat(auth_str+32,encry_str);
+					strcat(auth_str+32,"'");
+				}
 
-			if(time_zone != NULL)
-			{
-				strcat(auth_str+32," time_zone = '");
-				strcat(auth_str+32,time_zone);
-				strcat(auth_str+32,"'");
-			}
+				if(char_set != NULL)
+				{
+					strcat(auth_str+32," char_set = '");
+					strcat(auth_str+32,char_set);
+					strcat(auth_str+32,"'");
+				}
 
-			if(iso_level != NULL)
-			{
-				strcat(auth_str+32," iso_level = '");
-				strcat(auth_str+32,iso_level);
+				if(time_zone != NULL)
+				{
+					strcat(auth_str+32," time_zone = '");
+					strcat(auth_str+32,time_zone);
+					strcat(auth_str+32,"'");
+				}
+
+				if(iso_level != NULL)
+				{
+					strcat(auth_str+32," iso_level = '");
+					strcat(auth_str+32,iso_level);
+					strcat(auth_str+32,"'");
+				}
+
+				if(lock_timeout>0)
+				{
+					char i_buff[20];
+					strcat(auth_str+32," lock_timeout = ");
+					itoa(lock_timeout,i_buff,10);
+					strcat(auth_str+32,i_buff);
+				}
+
+				if(auto_commit)
+					strcat(auth_str+32," auto_commit = 'on'");
+				else
+					strcat(auth_str+32," auto_commit = 'off'");
+
+				strcat(auth_str+32," version = '");
+				strcat(auth_str+32,VERSION);
 				strcat(auth_str+32,"'");
-			}
 
-			if(lock_timeout>0)
-			{
-				char i_buff[20];
-				strcat(auth_str+32," lock_timeout = ");
-				itoa(lock_timeout,i_buff,10);
-				strcat(auth_str+32,i_buff);
+				insert_7(auth_str+32);
+				j = strlen(auth_str+32)+1;
+				rsa_encrypt(p_conn,auth_str,j+32);
+				send(sock,auth_str,((j+31)/32)*32+32,0);
+				init_turing_key(p_conn,(char*)key,32);
+				my_recv(p_conn,recv_buff,1);
+				DECRYPT(p_conn,recv_buff,1);
 			}
+			else if (isTLS || isGMSSL) {
+				p_conn->tongsuo = TRUE;
+				char recv_k[1];
+				SSL* ssl = NULL;
+				if (isTLS) {
+					/*发送"~tls~"*/
+					send(sock,"~tls~",5,0);
+					my_recv(p_conn, recv_k, 1);
+					ssl = SSL_new(ssl_ctx);
+				}
+				else {
+					/*发送"gmssl"*/
+					send(sock,"gmssl",5,0);
+					my_recv(p_conn, recv_k, 1);
+					ssl = SSL_new(gmssl_ctx);
+				}
+				if(recv_k[0] != 'K')
+				{
+					closesocket(sock);
+					#ifdef WIN32
+					free(p_conn->turing_data_r);
+					free(p_conn->turing_data_s);
+					#endif
+					free(p_conn);
+					return NULL;
+				}
+				//Output OpenSSL TRACE message
+				//Need Tongsuo compiled with enable-trace
+				//SSL_set_msg_callback(ssl, SSL_trace);
+				//SSL_set_msg_callback_arg(ssl, BIO_new_file("tongsuo-trace.log", "w"));
+
+				if (ssl == NULL) {
+					printf("Initialize ssl structure failed");
+					return NULL;
+				}
+				if (!SSL_set_fd(ssl, p_conn->sock)) {
+					printf("Bind socket with ssl structure failed");
+					return NULL;
+				}
+				if (SSL_connect(ssl) <= 0) {
+					printf("Connect ssl server failed");
+					return NULL;
+				}
+				p_conn->ssl = ssl;
+
+				strcpy(auth_str,"login database = ");
+				strcat(auth_str,db_name);
+				strcat(auth_str," user='");
+				strcat(auth_str,usr_name);
+				strcat(auth_str,"' password='");
+				strcat(auth_str,pass_word);
+				strcat(auth_str,"'");
+				if(encry_str != NULL)
+				{
+					strcat(auth_str," encryptor = '");
+					strcat(auth_str,encry_str);
+					strcat(auth_str,"'");
+				}
 
-			if(auto_commit)
-				strcat(auth_str+32," auto_commit = 'on'");
-			else
-				strcat(auth_str+32," auto_commit = 'off'");
+				if(char_set != NULL)
+				{
+					strcat(auth_str," char_set = '");
+					strcat(auth_str,char_set);
+					strcat(auth_str,"'");
+				}
 
-			strcat(auth_str+32," version = '");
-			strcat(auth_str+32,VERSION);
-			strcat(auth_str+32,"'");
+				if(time_zone != NULL)
+				{
+					strcat(auth_str," time_zone = '");
+					strcat(auth_str,time_zone);
+					strcat(auth_str,"'");
+				}
 
-			insert_7(auth_str+32);
-			j = strlen(auth_str+32)+1;
-			rsa_encrypt(p_conn,auth_str,j+32);
-			send(sock,auth_str,((j+31)/32)*32+32,0);
-			init_turing_key(p_conn,(char*)key,32);
-			my_recv(p_conn,recv_buff,1);
-			DECRYPT(p_conn,recv_buff,1);
+				if(iso_level != NULL)
+				{
+					strcat(auth_str," iso_level = '");
+					strcat(auth_str,iso_level);
+					strcat(auth_str,"'");
+				}
+
+				if(lock_timeout>0)
+				{
+					char i_buff[20];
+					strcat(auth_str," lock_timeout = ");
+					itoa(lock_timeout,i_buff,10);
+					strcat(auth_str,i_buff);
+				}
+
+				if(auto_commit)
+					strcat(auth_str," auto_commit = 'on'");
+				else
+					strcat(auth_str," auto_commit = 'off'");
+
+				strcat(auth_str," version = '");
+				strcat(auth_str,VERSION);
+				strcat(auth_str,"'");
+
+				SSL_write(ssl,auth_str,sizeof(auth_str));
+				SSL_read(ssl,recv_buff,32);
+			}
+			
 	#endif
         }
 		else
@@ -681,7 +867,13 @@ MY_DLL_API RhConnect* __stdcall	reConnect(RhConnect *p_conn)
 
 MY_DLL_API __int32	__stdcall	readConnect(RhConnect *p_conn,char *buff,int len)
 {
-	int r_len = recv(p_conn->sock,buff,len,0);
+	int r_len;
+	if (p_conn->ssl && p_conn->tongsuo) {
+		int r_len = SSL_read(p_conn->ssl,buff,len);
+	}
+	else {
+		r_len = recv(p_conn->sock,buff,len,0);
+	}
 	DECRYPT(p_conn,buff,r_len);
 	return r_len;
 }
@@ -768,11 +960,11 @@ MY_DLL_API  void __stdcall	setConnect(RhConnect *p_conn,char *title,char *val)
 }
 
 
-MY_DLL_API  RhConnect *  __stdcall ssl_connectDB(const char *ip_str,short int port,
-												 const char *db_name,const char *usr_name,
-												 const char *pass_word)
+MY_DLL_API  RhConnect *  __stdcall ssl_connectDB(const char *ssl_str,const char *ip_str,
+												 short int port,const char *db_name,
+												 const char *usr_name,const char *pass_word)
 {
-	return login(ip_str,port,db_name,usr_name,pass_word,NULL,NULL,NULL,NULL,0,TRUE,TRUE,FALSE);
+	return login(ssl_str,ip_str,port,db_name,usr_name,pass_word,NULL,NULL,NULL,NULL,0,TRUE,TRUE,FALSE);
 }
 
 
@@ -781,7 +973,7 @@ MY_DLL_API  RhConnect *  __stdcall connectDB(const char *ip_str,short int port,
 											 const char *db_name,const char *usr_name,
 											 const char *pass_word)
 {
-	return login(ip_str,port,db_name,usr_name,pass_word,NULL,NULL,NULL,NULL,0,TRUE,FALSE,FALSE);
+	return login(NULL,ip_str,port,db_name,usr_name,pass_word,NULL,NULL,NULL,NULL,0,TRUE,FALSE,FALSE);
 }
 
 MY_DLL_API int	__stdcall	closeConnect(RhConnect *p_conn)
@@ -886,35 +1078,56 @@ static void my_send(RhConnect *p_conn,void *buff,int len)
 {
 	int32 _s_n  = 1; //初始认为网络正常										
 #ifdef WIN32
-    if(p_conn->turing_data_s)
+    if(p_conn->use_ssl)
 	{	//加密发送
-		char *buff1;
-
-		if(len>2*1024)
-		{
-			buff1 = (char *)malloc(len);
-			memcpy(buff1,buff,len);
-			encrypt_buff(p_conn,buff1,len);
-			_s_n = send(p_conn->sock,p_conn->send_buff,p_conn->send_p,0);
-			p_conn->send_p = 0;
-			_s_n = send(p_conn->sock,buff1,len,0);
-			free(buff1);
-		}
-		else if(p_conn->send_p + len >= 8*1024)
-		{
-			_s_n = send(p_conn->sock,p_conn->send_buff,p_conn->send_p,0);
-			p_conn->send_p = 0;
-			memcpy(p_conn->send_buff,buff,len);
-			encrypt_buff(p_conn,p_conn->send_buff,len);
-			p_conn->send_p = len;
-		}
-		else
-		{
-			memcpy(p_conn->send_buff + p_conn->send_p,buff,len);
-			encrypt_buff(p_conn,p_conn->send_buff+p_conn->send_p,len);
-			p_conn->send_p += len;
+		if (p_conn->tongsuo) {
+			if(len>2*1024)
+			{
+				_s_n = SSL_write(p_conn->ssl,p_conn->send_buff,p_conn->send_p);
+				p_conn->send_p = 0;
+				_s_n = SSL_write(p_conn->ssl,buff,len);
+			}
+			else if(p_conn->send_p + len >= 8*1024)
+			{
+				_s_n = SSL_write(p_conn->ssl,p_conn->send_buff,p_conn->send_p);
+				p_conn->send_p = 0;
+				memcpy(p_conn->send_buff,buff,len);
+				p_conn->send_p = len;
+			}
+			else
+			{
+				memcpy(p_conn->send_buff + p_conn->send_p,buff,len);
+				p_conn->send_p += len;
+			}
 		}
+		else {
+			char *buff1;
 
+			if(len>2*1024)
+			{
+				buff1 = (char *)malloc(len);
+				memcpy(buff1,buff,len);
+				encrypt_buff(p_conn,buff1,len);
+				_s_n = send(p_conn->sock,p_conn->send_buff,p_conn->send_p,0);
+				p_conn->send_p = 0;
+				_s_n = send(p_conn->sock,buff1,len,0);
+				free(buff1);
+			}
+			else if(p_conn->send_p + len >= 8*1024)
+			{
+				_s_n = send(p_conn->sock,p_conn->send_buff,p_conn->send_p,0);
+				p_conn->send_p = 0;
+				memcpy(p_conn->send_buff,buff,len);
+				encrypt_buff(p_conn,p_conn->send_buff,len);
+				p_conn->send_p = len;
+			}
+			else
+			{
+				memcpy(p_conn->send_buff + p_conn->send_p,buff,len);
+				encrypt_buff(p_conn,p_conn->send_buff+p_conn->send_p,len);
+				p_conn->send_p += len;
+			}
+		}
 	}
 	else
     #endif 
@@ -960,8 +1173,12 @@ static void my_send_i2(RhConnect *p_conn,int16 i)
 
 static void my_flush(RhConnect *p_conn)
 {
-	if(p_conn->send_p)
+	if(p_conn->tongsuo)
 	{
+		SSL_write(p_conn->ssl,p_conn->send_buff,p_conn->send_p);
+		p_conn->send_p = 0;
+	}
+	else {
 		send(p_conn->sock,p_conn->send_buff,p_conn->send_p,0);
 		p_conn->send_p = 0;
 	}
@@ -970,16 +1187,26 @@ static void my_flush(RhConnect *p_conn)
 static int32 my_recv_int(RhConnect *p_conn)
 {
 	int32 n;
-	my_recv(p_conn,(char*)&n,sizeof(int32));
-	DECRYPT(p_conn,((char*)&n),sizeof(int32));
+	if (p_conn->tongsuo) {
+		SSL_read(p_conn->ssl, (char*)&n, sizeof(int32));
+	}
+	else {
+		my_recv(p_conn,(char*)&n,sizeof(int32));
+		DECRYPT(p_conn,((char*)&n),sizeof(int32));
+	}
 	return ntohl(n);
 }
 
 static __int64 my_recv_int64(RhConnect *p_conn)
 {
 	__int64 n;
-	my_recv(p_conn,(char*)&n,sizeof(__int64));
-	DECRYPT(p_conn,((char*)&n),sizeof(__int64));
+	if (p_conn->tongsuo) {
+		SSL_read(p_conn->ssl,(char*)&n,sizeof(__int64));
+	}
+	else {
+		my_recv(p_conn,(char*)&n,sizeof(__int64));
+		DECRYPT(p_conn,((char*)&n),sizeof(__int64));
+	}
 	_rh_hton8(&n);
 	return n;
 }
@@ -1045,7 +1272,13 @@ static __inline char * recv_str(RhConnect *p_conn,RhResult *p_result)
 	char	*p_buff = fmalloc(p_result,len+1);
 	while(len)
 	{
-		int n = recv(p_conn->sock,p_buff+off,len,0);
+		int n = 0;
+		if (p_conn->ssl && p_conn->tongsuo) {
+			n = SSL_read(p_conn->ssl, p_buff + off, len);
+		}
+		else {
+			n = recv(p_conn->sock, p_buff + off, len, 0);
+		}
 		if(n<0)
 			longjmp(p_conn->mark,1);
 		off += n;
@@ -1053,7 +1286,7 @@ static __inline char * recv_str(RhConnect *p_conn,RhResult *p_result)
 	}
 	p_buff[off] = 0x0;
 #ifdef WIN32
-	if(p_conn->turing_data_r)
+	if(p_conn->ssl && !p_conn->tongsuo)
 		decrypt_buff(p_conn,p_buff,len1);
 #endif
     return p_buff;
@@ -1066,8 +1299,13 @@ static AttrDesItem *recv_attr_des_item(RhConnect *p_conn,RhResult *p_result)
 
 	name_len = my_recv_int(p_conn);
 	p_item->name = (char *)fmalloc(p_result,name_len+1);
-	my_recv(p_conn,p_item->name,name_len);
-	DECRYPT(p_conn,p_item->name,name_len);
+	if (p_conn->tongsuo) {
+		SSL_read(p_conn->ssl, p_item->name, name_len);
+	}
+	else {
+		my_recv(p_conn,p_item->name,name_len);
+		DECRYPT(p_conn,p_item->name,name_len);
+	}
 	p_item->name[name_len] = 0x0; 	
 	p_item->type_id = my_recv_int(p_conn);
 	p_item->modi = my_recv_int(p_conn);
@@ -1109,7 +1347,13 @@ static __inline RhRecord *recv_record(RhConnect *p_conn,RhResult *p_result,char
 		d_len = my_recv_int(p_conn);
 		while(d_len)
 		{
-			int32 r_n = recv(p_conn->sock,(char*)(p_ret->bkmk+off),d_len,0);
+			int32 r_n;
+			if (p_conn->ssl && p_conn->tongsuo) {
+				r_n = SSL_read(p_conn->ssl, (char*)(p_ret->bkmk + off), d_len);
+			}
+			else {
+				r_n = recv(p_conn->sock, (char*)(p_ret->bkmk + off), d_len, 0);
+			}
 			if(r_n<0)
 				longjmp(p_conn->mark,1);
 			off += r_n;
@@ -1166,14 +1410,22 @@ static __inline RhRecord *recv_record(RhConnect *p_conn,RhResult *p_result,char
 		p_ret->fields[n].data = (char*)fmalloc(p_result,d_len+1);
 		while(d_len)
 		{
-			int32 r_n = recv(p_conn->sock,(char*)(p_ret->fields[n].data)+off,d_len,0);
+			int32 r_n;
+			if (p_conn->tongsuo) {
+				r_n = SSL_read(p_conn->ssl, (char*)(p_ret->fields[n].data) + off, d_len);
+			}
+			else {
+				r_n = recv(p_conn->sock, (char*)(p_ret->fields[n].data) + off, d_len, 0);
+			}
 			if(r_n<0)
 				longjmp(p_conn->mark,1);
 			off += r_n;
 			d_len -= r_n;
 		}
 		p_ret->fields[n].data[off] = 0x0;		/*考虑到方便字串操作*/ 
-		DECRYPT(p_conn,p_ret->fields[n].data,off);
+		if (!p_conn->tongsuo) {
+			DECRYPT(p_conn,p_ret->fields[n].data,off);
+		}
 		if(!p_ret->fields[n].len)
 			continue;
 		//end
@@ -1325,8 +1577,13 @@ static void recv_result(RhResult *p_result)
 		RhRecord *p_record;
 		RhRecord *p_record1;
 
-		my_recv(p_conn,&ch,1);
-		DECRYPT(p_conn,&ch,1);
+		if (p_conn->tongsuo) {
+			SSL_read(p_conn->ssl,&ch,1);
+		}
+		else {
+			my_recv(p_conn,&ch,1);
+			DECRYPT(p_conn,&ch,1);
+		}
 begin_rec:
 		if(ch=='R')
 		{
@@ -1337,8 +1594,13 @@ begin_rec:
 			{
 				if(p_result->b_cancel)
 				{
-					my_send(p_conn,".",1);
-					my_flush(p_conn);
+					if (p_conn->tongsuo) {
+						SSL_write(p_conn->ssl, ".", 1);
+					}
+					else {
+						my_send(p_conn,".",1);
+						my_flush(p_conn);
+					}
 				}
 				//my_send(p_conn,".",1);
 				//my_flush(p_conn);
@@ -1397,8 +1659,14 @@ begin_rec:
 			mrec_num=0;
 			for(;;)
 			{
-				my_recv(p_conn,&ch,1);
-				DECRYPT(p_conn,&ch,1);
+				if (p_conn->tongsuo) {
+					SSL_read(p_conn->ssl,&ch,1);
+				}
+				else {
+					my_recv(p_conn,&ch,1);
+					DECRYPT(p_conn,&ch,1);
+				}
+
 				if(ch=='R')
 				{			
 
@@ -1406,8 +1674,13 @@ begin_rec:
 					mrec_num++;
 					if((rec_num%20000)==0)
 					{
-						my_send(p_conn,".",1);
-						my_flush(p_conn);
+						if (p_conn->tongsuo) {
+							SSL_write(p_conn->ssl, ".", 1);
+						}
+						else {
+							my_send(p_conn, ".", 1);
+							my_flush(p_conn);
+						}
 					}
 				}
 				else
@@ -1424,7 +1697,12 @@ begin_rec:
 		else if (ch == '$')
 		{
 			int param_num;
-			my_recv(p_conn, &param_num, 4);
+			if (p_conn->tongsuo) {
+				SSL_read(p_conn->ssl, &param_num, 4);
+			}
+			else {
+				my_recv(p_conn, &param_num, 4);
+			}
 			_rh_hton4(&param_num);
 			break;
 		}
@@ -1457,8 +1735,14 @@ static RhResult *recv_results(RhConnect *p_conn)
 	p_result->is_ok = TRUE;
 	p_result->err_str = NULL;
 re_try:;	
-	my_recv(p_conn,buff,1);
-	DECRYPT(p_conn,buff,1);
+	if (p_conn->ssl && p_conn->tongsuo) {
+		SSL_read(p_conn->ssl, buff, 1);
+	}
+	else {
+		my_recv(p_conn,buff,1);
+		DECRYPT(p_conn,buff,1);
+	}
+
 	switch(buff[0])
 	{
 	case 'W':
diff --git a/xgconsole/xgconsole.vcxproj b/xgconsole/xgconsole.vcxproj
index e3823cc..adab656 100644
--- a/xgconsole/xgconsole.vcxproj
+++ b/xgconsole/xgconsole.vcxproj
@@ -102,7 +102,7 @@
     <ClCompile>
       <WarningLevel>TurnOffAllWarnings</WarningLevel>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>./include</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>F:\v12\third_party\Tongsuo-8.3.1\include;./include</AdditionalIncludeDirectories>
       <AdditionalUsingDirectories>./include</AdditionalUsingDirectories>
       <PreprocessorDefinitions>_X64;WIN32;_DEBUG;_CONSOLE;MY_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@@ -111,8 +111,9 @@
     </ClCompile>
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>ws2_32.lib;Netapi32.lib;Mswsock.lib;AdvApi32.lib;libcrypto.lib;libssl.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SubSystem>Console</SubSystem>
+      <AdditionalLibraryDirectories>F:\v12\third_party\Tongsuo-8.3.1;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -142,7 +143,7 @@
       <Optimization>MaxSpeed</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>./include</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>F:\v12\third_party\Tongsuo-8.3.1\include;./include</AdditionalIncludeDirectories>
       <AdditionalUsingDirectories>./include</AdditionalUsingDirectories>
       <OmitFramePointers>
       </OmitFramePointers>
@@ -155,8 +156,9 @@
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>msvcrt.lib;ws2_32.lib;Mswsock.lib;AdvApi32.lib;libcrypto_static.lib;libssl_static.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SubSystem>Console</SubSystem>
+      <AdditionalLibraryDirectories>F:\v12\third_party\Tongsuo-8.3.1;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
diff --git a/xgconsole/xgconsole.vcxproj.user b/xgconsole/xgconsole.vcxproj.user
index b8b033b..42910f0 100644
--- a/xgconsole/xgconsole.vcxproj.user
+++ b/xgconsole/xgconsole.vcxproj.user
@@ -1,7 +1,7 @@
 ﻿<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <LocalDebuggerCommandArguments>NNSL 192.168.2.93 5138 SYSTEM SYSDBA SYSDBA</LocalDebuggerCommandArguments>
+    <LocalDebuggerCommandArguments>GMSSL 192.168.66.228 5138 SYSTEM SYSDBA SYSDBA</LocalDebuggerCommandArguments>
     <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
