JavaScript
JavaScript
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.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var success = false;
var socket = new CkSocket();
// Connect to the server using TLS.
var bTls = true;
var maxWaitMs = 5000;
success = socket.Connect("example.com",5000,bTls,maxWaitMs);
if (success == false) {
console.log(socket.LastErrorText);
return;
}
// After connecting to a server that requests a client certificate, enumerate the certificate-
// authority distinguished names the server advertised as acceptable.
var numCAs = socket.NumSslAcceptableClientCAs;
var i;
for (i = 0; i <= numCAs - 1; i++) {
var caDn = socket.GetSslAcceptableClientCaDn(i);
if (socket.LastMethodSuccess == false) {
console.log(socket.LastErrorText);
return;
}
console.log(caDn);
}