Delphi ActiveX
Delphi ActiveX
Enumerate Server-Advertised Acceptable Client CAs
See more Socket/SSL/TLS Examples
Demonstrates Socket.GetSslAcceptableClientCaDn, which returns a certificate-authority distinguished name advertised by a TLS server when it requests a client certificate.
Background. Valid indexes range from 0 through
NumSslAcceptableClientCAs minus one. A client can use these names to select an appropriate client certificate.Chilkat Delphi ActiveX Downloads
var
success: Integer;
socket: TChilkatSocket;
bTls: Integer;
maxWaitMs: Integer;
numCAs: Integer;
i: Integer;
caDn: WideString;
begin
success := 0;
socket := TChilkatSocket.Create(Self);
// Connect to the server using TLS.
bTls := 1;
maxWaitMs := 5000;
success := socket.Connect('example.com',5000,bTls,maxWaitMs);
if (success = 0) then
begin
Memo1.Lines.Add(socket.LastErrorText);
Exit;
end;
// After connecting to a server that requests a client certificate, enumerate the certificate-
// authority distinguished names the server advertised as acceptable.
numCAs := socket.NumSslAcceptableClientCAs;
for i := 0 to numCAs - 1 do
begin
caDn := socket.GetSslAcceptableClientCaDn(i);
if (socket.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(socket.LastErrorText);
Exit;
end;
Memo1.Lines.Add(caDn);
end;