Sample code for 30+ languages & platforms
Delphi DLL

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 DLL Downloads

Delphi DLL
var
success: Boolean;
socket: HCkSocket;
bTls: Boolean;
maxWaitMs: Integer;
numCAs: Integer;
i: Integer;
caDn: PWideChar;

begin
success := False;

socket := CkSocket_Create();

//  Connect to the server using TLS.
bTls := True;
maxWaitMs := 5000;
success := CkSocket_Connect(socket,'example.com',5000,bTls,maxWaitMs);
if (success = False) then
  begin
    Memo1.Lines.Add(CkSocket__lastErrorText(socket));
    Exit;
  end;

//  After connecting to a server that requests a client certificate, enumerate the certificate-
//  authority distinguished names the server advertised as acceptable.
numCAs := CkSocket_getNumSslAcceptableClientCAs(socket);

for i := 0 to numCAs - 1 do
  begin
    caDn := CkSocket__getSslAcceptableClientCaDn(socket,i);
    if (CkSocket_getLastMethodSuccess(socket) = False) then
      begin
        Memo1.Lines.Add(CkSocket__lastErrorText(socket));
        Exit;
      end;
    Memo1.Lines.Add(caDn);
  end;

CkSocket_Dispose(socket);