Sample code for 30+ languages & platforms
Objective-C

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 Objective-C Downloads

Objective-C
#import <CkoSocket.h>
#import <NSString.h>

BOOL success = NO;

CkoSocket *socket = [[CkoSocket alloc] init];

//  Connect to the server using TLS.
BOOL bTls = YES;
int maxWaitMs = 5000;
success = [socket Connect: @"example.com" port: [NSNumber numberWithInt: 5000] ssl: bTls maxWaitMs: [NSNumber numberWithInt: maxWaitMs]];
if (success == NO) {
    NSLog(@"%@",socket.LastErrorText);
    return;
}

//  After connecting to a server that requests a client certificate, enumerate the certificate-
//  authority distinguished names the server advertised as acceptable.
int numCAs = [socket.NumSslAcceptableClientCAs intValue];
int i;
for (i = 0; i <= numCAs - 1; i++) {
    NSString *caDn = [socket GetSslAcceptableClientCaDn: [NSNumber numberWithInt: i]];
    if (socket.LastMethodSuccess == NO) {
        NSLog(@"%@",socket.LastErrorText);
        return;
    }

    NSLog(@"%@",caDn);
}