Sample code for 30+ languages & platforms
B4X

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

B4X
Dim success As Boolean = False

Dim socket As ChilkatSocket
socket.Initialize("socket")

'  Connect to the server using TLS.
Dim bTls As Boolean = True
Dim maxWaitMs As Int = 5000
success = socket.Connect("example.com", 5000, bTls, maxWaitMs)
If success = False Then
    Log(socket.LastErrorText)
    Return
End If


'  After connecting to a server that requests a client certificate, enumerate the certificate-
'  authority distinguished names the server advertised as acceptable.
Dim numCAs As Int = socket.NumSslAcceptableClientCAs
Dim i As Int
For i = 0 To numCAs - 1
    Dim caDn As String = socket.GetSslAcceptableClientCaDn(i)
    If socket.LastMethodSuccess = False Then
        Log(socket.LastErrorText)
        Return
    End If

    Log(caDn)
Next