From 1d1db571740d963a957696cef328bebe91a58a08 Mon Sep 17 00:00:00 2001 From: geby Date: Sun, 15 Feb 2015 09:09:30 +0000 Subject: [PATCH] ssl_openssl.pas - Added support for TLS_1.1 and TLS_1.2 (Dirk Jansen) git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@196 7c85be65-684b-0410-a082-b2ed4fbef004 --- blcksock.pas | 1 + ssl_openssl.pas | 4 ++++ ssl_openssl_lib.pas | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/blcksock.pas b/blcksock.pas index c1f4d3d..8739f73 100644 --- a/blcksock.pas +++ b/blcksock.pas @@ -244,6 +244,7 @@ type LT_SSLv3, LT_TLSv1, LT_TLSv1_1, + LT_TLSv1_2, LT_SSHv2 ); diff --git a/ssl_openssl.pas b/ssl_openssl.pas index 26c6a74..fbf35ba 100644 --- a/ssl_openssl.pas +++ b/ssl_openssl.pas @@ -426,6 +426,10 @@ begin Fctx := SslCtxNew(SslMethodV3); LT_TLSv1: Fctx := SslCtxNew(SslMethodTLSV1); + LT_TLSv1_1: + Fctx := SslCtxNew(SslMethodTLSV11); + LT_TLSv1_2: + Fctx := SslCtxNew(SslMethodTLSV12); LT_all: Fctx := SslCtxNew(SslMethodV23); else diff --git a/ssl_openssl_lib.pas b/ssl_openssl_lib.pas index 9fa6e8c..1f6647d 100644 --- a/ssl_openssl_lib.pas +++ b/ssl_openssl_lib.pas @@ -296,6 +296,16 @@ var EntryPoint = 'TLSv1_method')] function SslMethodTLSV1:PSSL_METHOD; external; + [DllImport(DLLSSLName, CharSet = CharSet.Ansi, + SetLastError = False, CallingConvention= CallingConvention.cdecl, + EntryPoint = 'TLSv1_1_method')] + function SslMethodTLSV11:PSSL_METHOD; external; + + [DllImport(DLLSSLName, CharSet = CharSet.Ansi, + SetLastError = False, CallingConvention= CallingConvention.cdecl, + EntryPoint = 'TLSv1_2_method')] + function SslMethodTLSV12:PSSL_METHOD; external; + [DllImport(DLLSSLName, CharSet = CharSet.Ansi, SetLastError = False, CallingConvention= CallingConvention.cdecl, EntryPoint = 'SSLv23_method')] @@ -706,6 +716,8 @@ var function SslMethodV2:PSSL_METHOD; function SslMethodV3:PSSL_METHOD; function SslMethodTLSV1:PSSL_METHOD; + function SslMethodTLSV11:PSSL_METHOD; + function SslMethodTLSV12:PSSL_METHOD; function SslMethodV23:PSSL_METHOD; function SslCtxUsePrivateKey(ctx: PSSL_CTX; pkey: SslPtr):Integer; function SslCtxUsePrivateKeyASN1(pk: integer; ctx: PSSL_CTX; d: AnsiString; len: integer):Integer; @@ -832,6 +844,8 @@ type TSslMethodV2 = function:PSSL_METHOD; cdecl; TSslMethodV3 = function:PSSL_METHOD; cdecl; TSslMethodTLSV1 = function:PSSL_METHOD; cdecl; + TSslMethodTLSV11 = function:PSSL_METHOD; cdecl; + TSslMethodTLSV12 = function:PSSL_METHOD; cdecl; TSslMethodV23 = function:PSSL_METHOD; cdecl; TSslCtxUsePrivateKey = function(ctx: PSSL_CTX; pkey: sslptr):Integer; cdecl; TSslCtxUsePrivateKeyASN1 = function(pk: integer; ctx: PSSL_CTX; d: sslptr; len: integer):Integer; cdecl; @@ -937,6 +951,8 @@ var _SslMethodV2: TSslMethodV2 = nil; _SslMethodV3: TSslMethodV3 = nil; _SslMethodTLSV1: TSslMethodTLSV1 = nil; + _SslMethodTLSV11: TSslMethodTLSV11 = nil; + _SslMethodTLSV12: TSslMethodTLSV12 = nil; _SslMethodV23: TSslMethodV23 = nil; _SslCtxUsePrivateKey: TSslCtxUsePrivateKey = nil; _SslCtxUsePrivateKeyASN1: TSslCtxUsePrivateKeyASN1 = nil; @@ -1114,6 +1130,22 @@ begin Result := nil; end; +function SslMethodTLSV11:PSSL_METHOD; +begin + if InitSSLInterface and Assigned(_SslMethodTLSV11) then + Result := _SslMethodTLSV11 + else + Result := nil; +end; + +function SslMethodTLSV12:PSSL_METHOD; +begin + if InitSSLInterface and Assigned(_SslMethodTLSV12) then + Result := _SslMethodTLSV12 + else + Result := nil; +end; + function SslMethodV23:PSSL_METHOD; begin if InitSSLInterface and Assigned(_SslMethodV23) then @@ -1850,6 +1882,8 @@ begin _SslMethodV2 := GetProcAddr(SSLLibHandle, 'SSLv2_method'); _SslMethodV3 := GetProcAddr(SSLLibHandle, 'SSLv3_method'); _SslMethodTLSV1 := GetProcAddr(SSLLibHandle, 'TLSv1_method'); + _SslMethodTLSV11 := GetProcAddr(SSLLibHandle, 'TLSv1_1_method'); + _SslMethodTLSV12 := GetProcAddr(SSLLibHandle, 'TLSv1_2_method'); _SslMethodV23 := GetProcAddr(SSLLibHandle, 'SSLv23_method'); _SslCtxUsePrivateKey := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey'); _SslCtxUsePrivateKeyASN1 := GetProcAddr(SSLLibHandle, 'SSL_CTX_use_PrivateKey_ASN1'); @@ -2045,6 +2079,8 @@ begin _SslMethodV2 := nil; _SslMethodV3 := nil; _SslMethodTLSV1 := nil; + _SslMethodTLSV11 := nil; + _SslMethodTLSV12 := nil; _SslMethodV23 := nil; _SslCtxUsePrivateKey := nil; _SslCtxUsePrivateKeyASN1 := nil;