Ben Copsey

Change SSL error detection code to fix issues with iPhone platform (Thanks to Ja…

…ne Sales for her report!)
... ... @@ -1366,14 +1366,12 @@ static NSError *ASIUnableToCreateRequestError;
NSString *reason = @"A connection failure occurred";
// We'll use a custom error message for common SSL errors, but you should always check underlying error if you want more details
// We'll use a custom error message for SSL errors, but you should always check underlying error if you want more details
// For some reason SecureTransport.h doesn't seem to be available on iphone, so error codes hard-coded
// Also, iPhone seems to handle errors differently from Mac OS X - a self-signed certificate returns a different error code on each platform, so we'll just provide a general error
if ([[underlyingError domain] isEqualToString:NSOSStatusErrorDomain]) {
if ([underlyingError code] == errSSLUnknownRootCert) {
reason = [NSString stringWithFormat:@"%@: Secure certificate had an untrusted root",reason];
} else if ([underlyingError code] == errSSLCertExpired) {
reason = [NSString stringWithFormat:@"%@: Secure certificate expired",reason];
} else if ([underlyingError code] >= -9807 || [underlyingError code] <= -9818) {
reason = [NSString stringWithFormat:@"%@: SSL problem (probably a bad certificate)",reason];
if ([underlyingError code] <= -9800 && [underlyingError code] >= -9818) {
reason = [NSString stringWithFormat:@"%@: SSL problem (possibily a bad/expired/self-signed certificate)",reason];
}
}
... ...
... ... @@ -625,7 +625,7 @@
GHAssertNotNil([request error],@"Failed to generate an error for a self-signed certificate");
// Just for testing the request generated a custom error description - don't do this! You should look at the domain / code of the underlyingError in your own programs.
BOOL success = ([[[request error] localizedDescription] isEqualToString:@"A connection failure occurred: Secure certificate had an untrusted root"]);
BOOL success = ([[[request error] localizedDescription] isEqualToString:@"A connection failure occurred: SSL problem (possibily a bad/expired/self-signed certificate)"]);
GHAssertTrue(success,@"Generated the wrong error for a self signed cert");
// Turn off certificate validation, and try again
... ...
... ... @@ -2,9 +2,9 @@
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">528</int>
<string key="IBDocument.SystemVersion">9G55</string>
<string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.43</string>
<string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
... ... @@ -39,14 +39,14 @@
<object class="IBUILabel" id="652745716">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 20}, {280, 91}}</string>
<string key="NSFrame">{{20, 20}, {280, 127}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string type="base64-UTF8" key="IBUIText">RGVtb25zdHJhdGVzIFBPU1RpbmcgY29udGVudCB0byBhIFVSTCwgc2hvd2luZyB1cGxvYWQgcHJvZ3Jl
c3MuCgpZb3UnbGwgb25seSBzZWUgYWNjdXJhdGUgcHJvZ3Jlc3MgZm9yIHVwbG9hZHMgd2hlbiB0aGUg
cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCLg</string>
cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCIChpbiAyLjIuMSBTREspA</string>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica</string>
<double key="NSSize">1.400000e+01</double>
... ... @@ -65,7 +65,7 @@ cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCLg</string>
<object class="IBUIButton" id="117120328">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 136}, {72, 37}}</string>
<string key="NSFrame">{{20, 161}, {72, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
... ... @@ -89,11 +89,15 @@ cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCLg</string>
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MyAwLjMwOTgwMzkzIDAuNTIxNTY4NjYAA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
</object>
<object class="IBUIProgressView" id="975702463">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 190}, {280, 9}}</string>
<string key="NSFrame">{{20, 215}, {280, 9}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
... ... @@ -239,6 +243,13 @@ cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCLg</string>
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Frameworks/libGHUnitIPhone/GHUNSObject+Swizzle.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UploadViewController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="actions">
... ... @@ -251,13 +262,14 @@ cmVxdWVzdCBib2R5IGlzIGxhcmdlciB0aGFuIDEyOEtCLg</string>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">UploadViewController.h</string>
<string key="minorKey">iPhone Sample/UploadViewController.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.LastKnownRelativeProjectPath">../asi-http-request.xcodeproj</string>
<string key="IBDocument.LastKnownRelativeProjectPath">../../iPhone.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">3.0</string>
</data>
</archive>
... ...