Sample code for 30+ languages & platforms
Objective-C

Transition from Http.GetServerSslCert to Http.GetServerCert

See more HTTP Examples

Provides instructions for replacing deprecated GetServerSslCert method calls with GetServerCert.

Chilkat Objective-C Downloads

Objective-C
#import <CkoHttp.h>
#import <NSString.h>
#import <CkoCert.h>

BOOL success = NO;

CkoHttp *http = [[CkoHttp alloc] init];
NSString *domain = @"chilkatsoft.com";
int port = 443;

// ------------------------------------------------------------------------
// The GetServerSslCert method is deprecated:

CkoCert *cert1 = [http GetServerSslCert: domain port: [NSNumber numberWithInt: port]];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%@",cert1.SubjectDN);

// ------------------------------------------------------------------------
// Do the equivalent using GetServerCert.
// Your application creates a new, empty certificate object which is passed 
// in the last argument and filled with the server certificate upon success.

CkoCert *cert2 = [[CkoCert alloc] init];
success = [http GetServerCert: domain port: [NSNumber numberWithInt: port] cert: cert2];
if (success == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%@",cert2.SubjectDN);