Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loSocket
LOCAL lnBTls
LOCAL lnMaxWaitMs
LOCAL lnNumCAs
LOCAL i
LOCAL lcCaDn

lnSuccess = 0

loSocket = CreateObject('Chilkat.Socket')

*  Connect to the server using TLS.
lnBTls = 1
lnMaxWaitMs = 5000
lnSuccess = loSocket.Connect("example.com",5000,lnBTls,lnMaxWaitMs)
IF (lnSuccess = 0) THEN
    ? loSocket.LastErrorText
    RELEASE loSocket
    CANCEL
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 = 0) THEN
        ? loSocket.LastErrorText
        RELEASE loSocket
        CANCEL
    ENDIF

    ? lcCaDn
NEXT

RELEASE loSocket