Permalink
Browse files

fixed bug that https request can’t be send in iOS5

  • Loading branch information...
1 parent 269f36c commit b39106076f3c611f6b91b085eebc80afe555e007 @OpenFibers committed Jul 9, 2013
Showing with 22 additions and 9 deletions.
  1. +22 −9 Classes/ASIHTTPRequest.m
View
@@ -1212,17 +1212,30 @@ - (void)startRequest
// see: http://iphonedevelopment.blogspot.com/2010/05/nsstream-tcp-and-ssl.html
NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
- [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
- [NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,
- kCFNull,kCFStreamSSLPeerName,
- nil];
+ [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
+ [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
+ [NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,
+ kCFNull,kCFStreamSSLPeerName,
+ @"kCFStreamSocketSecurityLevelTLSv1_0SSLv3", kCFStreamSSLLevel,
+ nil];
- CFReadStreamSetProperty((CFReadStreamRef)[self readStream],
- kCFStreamPropertySSLSettings,
+ CFReadStreamSetProperty((CFReadStreamRef)[self readStream],
+ kCFStreamPropertySSLSettings,
(CFTypeRef)sslProperties);
[sslProperties release];
- }
+ } else {
+ NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
+ [NSNumber numberWithBool:NO], kCFStreamSSLAllowsExpiredCertificates,
+ [NSNumber numberWithBool:NO], kCFStreamSSLAllowsAnyRoot,
+ [NSNumber numberWithBool:YES], kCFStreamSSLValidatesCertificateChain,
+ @"kCFStreamSocketSecurityLevelTLSv1_0SSLv3", kCFStreamSSLLevel,
+ nil];
+
+ CFReadStreamSetProperty((CFReadStreamRef)[self readStream],
+ kCFStreamPropertySSLSettings,
+ (CFTypeRef)sslProperties);
+ [sslProperties release];
+ }
// Tell CFNetwork to use a client certificate
if (clientCertificateIdentity) {
@@ -4866,7 +4879,7 @@ + (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterva
// RFC 2612 says max-age must override any Expires header
if (maxAge) {
- return [[NSDate date] addTimeInterval:maxAge];
+ return [[NSDate date] dateByAddingTimeInterval:maxAge];
} else {
NSString *expires = [responseHeaders objectForKey:@"Expires"];
if (expires) {

0 comments on commit b391060

Please sign in to comment.