Patched issue #263 - (can't revert 'validatesSecureCertificate' once set to 'NO' on new requests)
Showing
1 changed file
with
22 additions
and
10 deletions
| @@ -1198,18 +1198,28 @@ static NSOperationQueue *sharedQueue = nil; | @@ -1198,18 +1198,28 @@ static NSOperationQueue *sharedQueue = nil; | ||
| 1198 | // Handle SSL certificate settings | 1198 | // Handle SSL certificate settings |
| 1199 | // | 1199 | // |
| 1200 | 1200 | ||
| 1201 | - if([[[[self url] scheme] lowercaseString] isEqualToString:@"https"]) { | 1201 | + if([[[[self url] scheme] lowercaseString] isEqualToString:@"https"]) { |
| 1202 | - | 1202 | + |
| 1203 | - NSMutableDictionary *sslProperties = [NSMutableDictionary dictionaryWithCapacity:1]; | ||
| 1204 | - | ||
| 1205 | // Tell CFNetwork not to validate SSL certificates | 1203 | // Tell CFNetwork not to validate SSL certificates |
| 1206 | if (![self validatesSecureCertificate]) { | 1204 | if (![self validatesSecureCertificate]) { |
| 1207 | - [sslProperties setObject:(NSString *)kCFBooleanFalse forKey:(NSString *)kCFStreamSSLValidatesCertificateChain]; | 1205 | + // see: http://iphonedevelopment.blogspot.com/2010/05/nsstream-tcp-and-ssl.html |
| 1208 | - } | 1206 | + |
| 1209 | - | 1207 | + NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys: |
| 1208 | + [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates, | ||
| 1209 | + [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot, | ||
| 1210 | + [NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain, | ||
| 1211 | + kCFNull,kCFStreamSSLPeerName, | ||
| 1212 | + nil]; | ||
| 1213 | + | ||
| 1214 | + CFReadStreamSetProperty((CFReadStreamRef)[self readStream], | ||
| 1215 | + kCFStreamPropertySSLSettings, | ||
| 1216 | + (CFTypeRef)sslProperties); | ||
| 1217 | + } | ||
| 1218 | + | ||
| 1210 | // Tell CFNetwork to use a client certificate | 1219 | // Tell CFNetwork to use a client certificate |
| 1211 | if (clientCertificateIdentity) { | 1220 | if (clientCertificateIdentity) { |
| 1212 | - | 1221 | + NSMutableDictionary *sslProperties = [NSMutableDictionary dictionaryWithCapacity:1]; |
| 1222 | + | ||
| 1213 | NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[clientCertificates count]+1]; | 1223 | NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[clientCertificates count]+1]; |
| 1214 | 1224 | ||
| 1215 | // The first object in the array is our SecIdentityRef | 1225 | // The first object in the array is our SecIdentityRef |
| @@ -1219,10 +1229,12 @@ static NSOperationQueue *sharedQueue = nil; | @@ -1219,10 +1229,12 @@ static NSOperationQueue *sharedQueue = nil; | ||
| 1219 | for (id cert in clientCertificates) { | 1229 | for (id cert in clientCertificates) { |
| 1220 | [certificates addObject:cert]; | 1230 | [certificates addObject:cert]; |
| 1221 | } | 1231 | } |
| 1232 | + | ||
| 1222 | [sslProperties setObject:certificates forKey:(NSString *)kCFStreamSSLCertificates]; | 1233 | [sslProperties setObject:certificates forKey:(NSString *)kCFStreamSSLCertificates]; |
| 1234 | + | ||
| 1235 | + CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, sslProperties); | ||
| 1223 | } | 1236 | } |
| 1224 | - | 1237 | + |
| 1225 | - CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, sslProperties); | ||
| 1226 | } | 1238 | } |
| 1227 | 1239 | ||
| 1228 | // | 1240 | // |
-
Please register or login to post a comment