ssl_cryptlib.pas Support for TLS1.2 and 1.3 (by ACBr)

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@257 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2022-01-16 14:15:49 +00:00
parent 9ebe828363
commit 2330641499

View File

@ -79,6 +79,10 @@ and @link(TCustomSSL.password). You can use special SSH channels too, see
{$ENDIF}
{$H+}
{$IFDEF NEXTGEN}
{$ZEROBASEDSTRINGS OFF}
{$ENDIF}
unit ssl_cryptlib;
interface
@ -296,7 +300,7 @@ begin
FcryptSession := CRYPT_SESSION(CRYPT_SESSION_NONE);
if server then
case FSSLType of
LT_all, LT_SSLv3, LT_TLSv1, LT_TLSv1_1:
LT_all, LT_SSLv3, LT_TLSv1, LT_TLSv1_1, LT_TLSv1_2, LT_TLSv1_3:
st := CRYPT_SESSION_SSL_SERVER;
LT_SSHv2:
st := CRYPT_SESSION_SSH_SERVER;
@ -305,7 +309,7 @@ begin
end
else
case FSSLType of
LT_all, LT_SSLv3, LT_TLSv1, LT_TLSv1_1:
LT_all, LT_SSLv3, LT_TLSv1, LT_TLSv1_1, LT_TLSv1_2, LT_TLSv1_3:
st := CRYPT_SESSION_SSL;
LT_SSHv2:
st := CRYPT_SESSION_SSH;
@ -322,6 +326,10 @@ begin
x := 1;
LT_TLSv1_1:
x := 2;
LT_TLSv1_2:
x := 3;
LT_TLSv1_3:
x := 4;
end;
if x >= 0 then
if not SSLCheck(cryptSetAttribute(FCryptSession, CRYPT_SESSINFO_VERSION, x)) then
@ -507,7 +515,7 @@ begin
if FcryptSession = CRYPT_SESSION(CRYPT_SESSION_NONE) then
Exit;
cryptGetAttribute(FCryptSession, CRYPT_SESSINFO_VERSION, x);
if FSSLType in [LT_SSLv3, LT_TLSv1, LT_TLSv1_1, LT_all] then
if FSSLType in [LT_SSLv3, LT_TLSv1, LT_TLSv1_1, LT_TLSv1_2, LT_TLSv1_3, LT_all] then
case x of
0:
Result := 'SSLv3';
@ -515,6 +523,10 @@ begin
Result := 'TLSv1';
2:
Result := 'TLSv1.1';
3:
Result := 'TLSv1.2';
4:
Result := 'TLSv1.3';
end;
if FSSLType in [LT_SSHv2] then
case x of
@ -677,5 +689,3 @@ initialization
finalization
cryptEnd;
end.