Sample code for 30+ languages & platforms
Lianja

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

Lianja
llSuccess = .F.

loSocket = createobject("CkSocket")

//  Connect to the server using TLS.
llBTls = .T.
lnMaxWaitMs = 5000
llSuccess = loSocket.Connect("example.com",5000,llBTls,lnMaxWaitMs)
if (llSuccess = .F.) then
    ? loSocket.LastErrorText
    release loSocket
    return
endif

//  After connecting to a server that requests a client certificate, enumerate the certificate-
//  authority distinguished names the server advertised as acceptable.
lnNumCAs = loSocket.NumSslAcceptableClientCAs

for i = 0 to lnNumCAs - 1
    lcCaDn = loSocket.GetSslAcceptableClientCaDn(i)
    if (loSocket.LastMethodSuccess = .F.) then
        ? loSocket.LastErrorText
        release loSocket
        return
    endif

    ? lcCaDn
next


release loSocket