Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added SSL level #274

Closed
wants to merge 1 commit into from

1 participant

@exalted

I needed to force my requests for a specific SSL level so that any secure request can be set with a specific security level of a socket stream

@exalted exalted Added SSL Level
Any secure request can be set with a specific security level of a socket
stream
43e3f17
@exalted exalted closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 25, 2011
  1. @exalted

    Added SSL Level

    exalted authored
    Any secure request can be set with a specific security level of a socket
    stream
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 0 deletions.
  1. +5 −0 Classes/ASIHTTPRequest.h
  2. +7 −0 Classes/ASIHTTPRequest.m
View
5 Classes/ASIHTTPRequest.h
@@ -370,6 +370,10 @@ typedef void (^ASIDataBlock)(NSData *data);
SecIdentityRef clientCertificateIdentity;
NSArray *clientCertificates;
+ // Security level of a socket stream.
+ // By default, a stream’s security level is kCFStreamSocketSecurityLevelNegotiatedSSL.
+ NSString *securityLevel;
+
// Details on the proxy to use - you could set these yourself, but it's probably best to let ASIHTTPRequest detect the system proxy settings
NSString *proxyHost;
int proxyPort;
@@ -964,6 +968,7 @@ typedef void (^ASIDataBlock)(NSData *data);
@property (assign, readonly) unsigned long long partialDownloadSize;
@property (assign) BOOL shouldRedirect;
@property (assign) BOOL validatesSecureCertificate;
+@property (retain) NSString *securityLevel;
@property (assign) BOOL shouldCompressRequestBody;
@property (retain) NSURL *PACurl;
@property (retain) NSString *authenticationScheme;
View
7 Classes/ASIHTTPRequest.m
@@ -298,6 +298,7 @@ - (id)initWithURL:(NSURL *)newURL
[self setUseSessionPersistence:YES];
[self setUseCookiePersistence:YES];
[self setValidatesSecureCertificate:YES];
+ [self setSecurityLevel:(NSString *)kCFStreamSocketSecurityLevelNegotiatedSSL];
[self setRequestCookies:[[[NSMutableArray alloc] init] autorelease]];
[self setDidStartSelector:@selector(requestStarted:)];
[self setDidReceiveResponseHeadersSelector:@selector(request:didReceiveResponseHeaders:)];
@@ -1222,6 +1223,9 @@ - (void)startRequest
[sslProperties setObject:certificates forKey:(NSString *)kCFStreamSSLCertificates];
}
+ // Tell CFNetwork to use specified security level for the socket stream
+ [sslProperties setObject:[self securityLevel] forKey:(NSString *)kCFStreamSSLLevel];
+
CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertySSLSettings, sslProperties);
}
@@ -1621,6 +1625,7 @@ - (ASIHTTPRequest *)HEADRequest
[headRequest setValidatesSecureCertificate:[self validatesSecureCertificate]];
[headRequest setClientCertificateIdentity:clientCertificateIdentity];
[headRequest setClientCertificates:[[clientCertificates copy] autorelease]];
+ [headRequest setSecurityLevel:[self securityLevel]];
[headRequest setPACurl:[self PACurl]];
[headRequest setShouldPresentCredentialsBeforeChallenge:[self shouldPresentCredentialsBeforeChallenge]];
[headRequest setNumberOfTimesToRetryOnTimeout:[self numberOfTimesToRetryOnTimeout]];
@@ -4072,6 +4077,7 @@ - (id)copyWithZone:(NSZone *)zone
[newRequest setValidatesSecureCertificate:[self validatesSecureCertificate]];
[newRequest setClientCertificateIdentity:clientCertificateIdentity];
[newRequest setClientCertificates:[[clientCertificates copy] autorelease]];
+ [newRequest setSecurityLevel:[self securityLevel]];
[newRequest setPACurl:[self PACurl]];
[newRequest setShouldPresentCredentialsBeforeChallenge:[self shouldPresentCredentialsBeforeChallenge]];
[newRequest setNumberOfTimesToRetryOnTimeout:[self numberOfTimesToRetryOnTimeout]];
@@ -5020,6 +5026,7 @@ - (void)setRequestRedirectedBlock:(ASIBasicBlock)aRedirectBlock
@synthesize updatedProgress;
@synthesize shouldRedirect;
@synthesize validatesSecureCertificate;
+@synthesize securityLevel;
@synthesize needsRedirect;
@synthesize redirectCount;
@synthesize shouldCompressRequestBody;
Something went wrong with that request. Please try again.