Sample code for 30+ languages & platforms
Chilkat2-Python

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 Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

socket = chilkat2.Socket()

# Connect to the server using TLS.
bTls = True
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
if (success == False):
    print(socket.LastErrorText)
    sys.exit()

# After connecting to a server that requests a client certificate, enumerate the certificate-
# authority distinguished names the server advertised as acceptable.
numCAs = socket.NumSslAcceptableClientCAs

for i in range(0,numCAs):
    caDn = socket.GetSslAcceptableClientCaDn(i)
    if (socket.LastMethodSuccess == False):
        print(socket.LastErrorText)
        sys.exit()

    print(caDn)