Ruby
Ruby
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 Ruby Downloads
require 'chilkat'
success = false
socket = Chilkat::CkSocket.new()
# Connect to the server using TLS.
bTls = true
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
if (success == false)
print socket.lastErrorText() + "\n";
exit
end
# After connecting to a server that requests a client certificate, enumerate the certificate-
# authority distinguished names the server advertised as acceptable.
numCAs = socket.get_NumSslAcceptableClientCAs()
for i in 0 .. numCAs - 1
caDn = socket.getSslAcceptableClientCaDn(i)
if (socket.get_LastMethodSuccess() == false)
print socket.lastErrorText() + "\n";
exit
end
print caDn + "\n";
end