Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid overriding of the property kCFStreamPropertySSLSettings #343

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 28 additions & 29 deletions Classes/ASIHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1205,44 +1205,43 @@ - (void)startRequest
// Handle SSL certificate settings
//

if([[[[self url] scheme] lowercaseString] isEqualToString:@"https"]) {

// Tell CFNetwork not to validate SSL certificates
if (![self validatesSecureCertificate]) {
// 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];

CFReadStreamSetProperty((CFReadStreamRef)[self readStream],
kCFStreamPropertySSLSettings,
(CFTypeRef)sslProperties);
[sslProperties release];
}
if([[[[self url] scheme] lowercaseString] isEqualToString:@"https"]) {

// Properties for the SSL connection
NSMutableDictionary *sslProperties = [NSMutableDictionary dictionary];

// Tell CFNetwork to use a client certificate
if (clientCertificateIdentity) {
NSMutableDictionary *sslProperties = [NSMutableDictionary dictionaryWithCapacity:1];
NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[clientCertificates count]+1];

NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[clientCertificates count]+1];

// The first object in the array is our SecIdentityRef
[certificates addObject:(id)clientCertificateIdentity];

// If we've added any additional certificates, add them too
for (id cert in clientCertificates) {
[certificates addObject:cert];
}
// The first object in the array is our SecIdentityRef
[certificates addObject:(id)clientCertificateIdentity];

// If we've added any additional certificates, add them too
for (id cert in clientCertificates) {
[certificates addObject:cert];
}

[sslProperties setObject:certificates forKey:(NSString *)kCFStreamSSLCertificates];
}

// Tell CFNetwork not to validate SSL certificates
if (![self validatesSecureCertificate]) {
// see: http://iphonedevelopment.blogspot.com/2010/05/nsstream-tcp-and-ssl.html

NSMutableDictionary *sslNotValidateCertificate = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
[NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
[NSNumber numberWithBool:NO], kCFStreamSSLValidatesCertificateChain,
kCFNull,kCFStreamSSLPeerName,
nil];

CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, sslProperties);
[sslProperties addEntriesFromDictionary:sslNotValidateCertificate];
[sslNotValidateCertificate release];
}

// Set the properties
CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, sslProperties);
}

//
Expand Down