Sample code for 30+ languages & platforms
Objective-C

Revert a TLS Connection to Plain TCP

See more Socket/SSL/TLS Examples

Demonstrates Socket.ConvertFromSsl, which ends the TLS layer while leaving the underlying TCP connection open for subsequent unencrypted communication.

Background. This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is currently active on the connection.

Chilkat Objective-C Downloads

Objective-C
#import <CkoSocket.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;
}

//  End the TLS layer while keeping the underlying TCP connection open for subsequent unencrypted
//  communication.  This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is
//  active.
success = [socket ConvertFromSsl];
if (success == NO) {
    NSLog(@"%@",socket.LastErrorText);
    return;
}

NSLog(@"%@",@"Reverted to a plain TCP connection.");