PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkSocket.pb"
Procedure ChilkatExample()
success.i = 0
socket.i = CkSocket::ckCreate()
If socket.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Connect to the server using TLS.
bTls.i = 1
maxWaitMs.i = 5000
success = CkSocket::ckConnect(socket,"example.com",5000,bTls,maxWaitMs)
If success = 0
Debug CkSocket::ckLastErrorText(socket)
CkSocket::ckDispose(socket)
ProcedureReturn
EndIf
; After connecting to a server that requests a client certificate, enumerate the certificate-
; authority distinguished names the server advertised as acceptable.
numCAs.i = CkSocket::ckNumSslAcceptableClientCAs(socket)
i.i
For i = 0 To numCAs - 1
caDn.s = CkSocket::ckGetSslAcceptableClientCaDn(socket,i)
If CkSocket::ckLastMethodSuccess(socket) = 0
Debug CkSocket::ckLastErrorText(socket)
CkSocket::ckDispose(socket)
ProcedureReturn
EndIf
Debug caDn
Next
CkSocket::ckDispose(socket)
ProcedureReturn
EndProcedure