Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oSocket
LOCAL nBTls
LOCAL nMaxWaitMs
LOCAL nNumCAs
LOCAL i
LOCAL cCaDn

nSuccess := 0

oSocket := CreateObject("Chilkat.Socket")

//  Connect to the server using TLS.
nBTls := 1
nMaxWaitMs := 5000
nSuccess := oSocket:Connect("example.com", 5000, nBTls, nMaxWaitMs)
IF (nSuccess == 0)
    ? oSocket:LastErrorText
    oSocket:destroy()
    RETURN
ENDIF

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

FOR i := 0 TO nNumCAs - 1
    cCaDn := oSocket:GetSslAcceptableClientCaDn(i)
    IF (oSocket:LastMethodSuccess == 0)
        ? oSocket:LastErrorText
        oSocket:destroy()
        RETURN
    ENDIF

    ? cCaDn
NEXT

oSocket:destroy()