JDjimenezdelgado / wtclient

Automatically exported from code.google.com/p/wtclient
0 stars 0 forks source link

fix kCFStreamErrorDomainSSL error for HTTPS(SSL) #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have found the code not correctly supported https(SSL) server on device or 
simulator, it reports kCFStreamErrorDomainSSL error when connect to https(SSL) 
server, i do the following to fix it. 

At openStream before calling CFReadStreamOpen, add the following code to not 
check SSL:

if (requestStream) {
    // We don't want to validate the HTTPS certificate.
    CFMutableDictionaryRef securityDictRef = CFDictionaryCreateMutable (kCFAllocatorDefault, 
                                                            0 , 
                                                            & kCFTypeDictionaryKeyCallBacks, 
                                                            & kCFTypeDictionaryValueCallBacks);

    if (securityDictRef != NULL ){
        CFDictionarySetValue (securityDictRef, kCFStreamSSLValidatesCertificateChain, kCFBooleanFalse);
        CFReadStreamSetProperty (requestStream, kCFStreamPropertySSLSettings , securityDictRef);
        CFRelease (securityDictRef);
    }
}

Original issue reported on code.google.com by bygree...@gmail.com on 8 Feb 2011 at 8:26