Skip to content

Commit 8baf085

Browse files
author
Lars Steiger
committed
We don't retrieve SSL certificates below OSX 10.6.
1 parent b59e46a commit 8baf085

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

FsprgEmbeddedStore/FsprgEmbeddedStoreController.m

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#import "FsprgOrderView.h"
1111
#import "FsprgOrderDocumentRepresentation.h"
1212

13+
// We don't retrieve SSL certificates below OSX 10.6
14+
#define RETRIEVE_SSL_CERTIFICATES defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
15+
1316

1417
@interface FsprgEmbeddedStoreController (Private)
1518

@@ -331,18 +334,21 @@ - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)
331334

332335
- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
333336
{
337+
#if RETRIEVE_SSL_CERTIFICATES
334338
NSURL *URL = [request URL];
335339
NSString *host = [URL host];
336340
if ([[self hostCertificates] objectForKey:host] == nil)
337341
{
338342
NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
339343
[[self connectionsToRequests] setObject:request forKey:connection];
340344
}
345+
#endif
341346
return request;
342347
}
343348

344349
#pragma mark - NURLConnection delegate
345350

351+
#if RETRIEVE_SSL_CERTIFICATES
346352
- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse
347353
{
348354
return cachedResponse;
@@ -373,25 +379,24 @@ - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectio
373379

374380
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
375381
{
376-
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
377382
SecTrustRef trustRef = [[challenge protectionSpace] serverTrust];
378383
SecTrustResultType resultType;
379384
SecTrustEvaluate(trustRef, &resultType);
380-
CFIndex count = SecTrustGetCertificateCount(trustRef);
381-
382-
NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:count];
385+
NSUInteger count = (NSUInteger)SecTrustGetCertificateCount(trustRef);
386+
387+
NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:count];
383388
CFIndex idx;
384389
for (idx = 0; idx < count; idx++) {
385390
SecCertificateRef certificateRef = SecTrustGetCertificateAtIndex(trustRef, idx);
386391
[certificates addObject:(id)certificateRef];
387392
}
388-
393+
389394
NSURLRequest *request = [[self connectionsToRequests] objectForKey:connection];
390395
NSURL *URL = [request URL];
391396
NSString *host = [URL host];
392397
[[self hostCertificates] setObject:certificates forKey:host];
393-
#endif
394398
}
399+
#endif
395400

396401

397402
- (void)dealloc

FsprgEmbeddedStore/FsprgOrderView.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#import "FsprgOrderView.h"
1010
#import "FsprgOrderDocumentRepresentation.h"
11-
#import "FsprgOrder.h"
1211
#import "FsprgEmbeddedStoreController.h"
1312

1413

@@ -66,14 +65,17 @@ - (void)layout
6665
if([[self subviews] count] == 0) {
6766
[self setFrame:[[self superview] frame]];
6867

69-
FsprgOrderDocumentRepresentation *representation = [[self dataSource] representation];
68+
FsprgOrderDocumentRepresentation *representation = (FsprgOrderDocumentRepresentation *)[[self dataSource] representation];
7069
FsprgOrder *order = [representation order];
7170

7271
FsprgEmbeddedStoreController *delegate = [[[[self dataSource] webFrame] webView] UIDelegate];
7372
NSView *newSubview = [[delegate delegate] viewWithFrame:[self frame] forOrder:order];
7473
[self addSubview:newSubview];
7574
}
75+
76+
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
7677
[super layout];
78+
#endif
7779
}
7880

7981
- (void)viewDidMoveToHostWindow

0 commit comments

Comments
 (0)