Perl
Chilkat2 Perl
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 Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $socket = Chilkat2::Socket->new;
# Connect to the server using TLS.
my $bTls = 1;
my $maxWaitMs = 5000;
my $success = $socket->Connect('example.com', 5000, $bTls, $maxWaitMs);
if (!$success) {
print $socket->LastErrorText, "\n";
exit;
}
# After connecting to a server that requests a client certificate, enumerate the certificate-
# authority distinguished names the server advertised as acceptable.
my $numCAs = $socket->NumSslAcceptableClientCAs;
for my $i (0 .. $numCAs - 1) {
my $caDn = $socket->GetSslAcceptableClientCaDn($i);
if (!$socket->LastMethodSuccess) {
print $socket->LastErrorText, "\n";
exit;
}
print $caDn, "\n";
}