Sample code for 30+ languages & platforms
Tcl

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

Tcl

load ./chilkat.dll

set success 0

set socket [new_CkSocket]

#  Connect to the server using TLS.
set bTls 1
set maxWaitMs 5000
set success [CkSocket_Connect $socket "example.com" 5000 $bTls $maxWaitMs]
if {$success == 0} then {
    puts [CkSocket_lastErrorText $socket]
    delete_CkSocket $socket
    exit
}

#  After connecting to a server that requests a client certificate, enumerate the certificate-
#  authority distinguished names the server advertised as acceptable.
set numCAs [CkSocket_get_NumSslAcceptableClientCAs $socket]

for {set i 0} {$i <= [expr $numCAs - 1]} {incr i} {
    set caDn [CkSocket_getSslAcceptableClientCaDn $socket $i]
    if {[CkSocket_get_LastMethodSuccess $socket] == 0} then {
        puts [CkSocket_lastErrorText $socket]
        delete_CkSocket $socket
        exit
    }

    puts "$caDn"
}

delete_CkSocket $socket