Skip to content
Browse files

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

…hanks to Jane Sales for her report!)
  • Loading branch information...
1 parent 4dc5766 commit 03a71b6a61018521af4eec75e0adb556d80ae74f @pokeb committed Jun 9, 2009
Showing with 26 additions and 16 deletions.
  1. +5 −7 Classes/ASIHTTPRequest.m
  2. +1 −1 Classes/Tests/ASIHTTPRequestTests.m
  3. +20 −8 iPhone Sample/XIBs/UploadProgress.xib
View
12 Classes/ASIHTTPRequest.m
@@ -1366,14 +1366,12 @@ - (void)handleStreamError
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];
}
}
View
2 Classes/Tests/ASIHTTPRequestTests.m
@@ -625,7 +625,7 @@ - (void)testSSL
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
View
28 iPhone Sample/XIBs/UploadProgress.xib
@@ -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>

0 comments on commit 03a71b6

Please sign in to comment.
Something went wrong with that request. Please try again.