PHP
Chilkat2 PHP
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 PHP Downloads
<?php
use Chilkat2\Socket;
$socket = new Socket();
// Connect to the server using TLS.
$bTls = true;
$maxWaitMs = 5000;
try {
$socket->Connect('example.com', 5000, $bTls, $maxWaitMs);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
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 = 0; $i < $numCAs; $i++) {
try {
$caDn = $socket->GetSslAcceptableClientCaDn($i);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo $caDn, "\n";
}