Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Net/Net.CrossSslSocket.Base.pas
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ TCrossSslSocketBase = class(TCrossSocket, ICrossSslSocket)
const APassword: string = ''); virtual;

procedure SetVerifyPeer(const AValue: Boolean); virtual;
{ TLSOPT-2 (fork-only): override negotiated cipher list (TLS 1.2 and below).
ACipherList is an OpenSSL cipher-list string. Empty = keep _InitSslCtx default. }
procedure SetCipherList(const ACipherList: string); virtual; abstract;

property Ssl: Boolean read GetSsl;
property VerifyPeer: Boolean read GetVerifyPeer write SetVerifyPeer;
Expand Down Expand Up @@ -407,6 +410,7 @@ procedure TCrossSslSocketBase.SetVerifyPeer(const AValue: Boolean);
end;
end;


procedure TCrossSslSocketBase.AddCACertificate(const ABuf: Pointer;
const ASize: Integer);
begin
Expand Down
20 changes: 20 additions & 0 deletions Net/Net.CrossSslSocket.OpenSSL.pas
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ TCrossOpenSslSocket = class(TCrossSslSocketBase)
const ASize: Integer); overload; override;
procedure SetPrivateKey(const APKeyBuf: Pointer; const APKeyBufSize: Integer;
const APassword: string); overload; override;
{ Override the TLS 1.2 cipher list via SSL_CTX_set_cipher_list. }
procedure SetCipherList(const ACipherList: string); override;
end;

{$IFDEF CROSS_OPENSSL_SELFTEST}
Expand Down Expand Up @@ -1170,6 +1172,24 @@ procedure TCrossOpenSslSocket.SetPrivateKey(const APKeyBuf: Pointer;
end;
end;

procedure TCrossOpenSslSocket.SetCipherList(const ACipherList: string);
var
LAnsi: AnsiString;
begin
if not Ssl or (FSslCtx = nil) or (ACipherList = '') then Exit;

BeginTlsConfigUpdate;
try
LAnsi := AnsiString(ACipherList);
if SSL_CTX_set_cipher_list(FSslCtx, PAnsiChar(LAnsi)) <> 1 then
raise ESsl.Create(
'SetCipherList: SSL_CTX_set_cipher_list rejected "' + ACipherList +
'" (no matching ciphers)');
finally
EndTlsConfigUpdate;
end;
end;

procedure TCrossOpenSslSocket.TriggerConnected(const AConnection: ICrossConnection);
var
LConnection: TCrossOpenSslConnection;
Expand Down