|
10 | 10 | #import "FsprgOrderView.h" |
11 | 11 | #import "FsprgOrderDocumentRepresentation.h" |
12 | 12 |
|
| 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 | + |
13 | 16 |
|
14 | 17 | @interface FsprgEmbeddedStoreController (Private) |
15 | 18 |
|
@@ -331,18 +334,21 @@ - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *) |
331 | 334 |
|
332 | 335 | - (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource |
333 | 336 | { |
| 337 | +#if RETRIEVE_SSL_CERTIFICATES |
334 | 338 | NSURL *URL = [request URL]; |
335 | 339 | NSString *host = [URL host]; |
336 | 340 | if ([[self hostCertificates] objectForKey:host] == nil) |
337 | 341 | { |
338 | 342 | NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease]; |
339 | 343 | [[self connectionsToRequests] setObject:request forKey:connection]; |
340 | 344 | } |
| 345 | +#endif |
341 | 346 | return request; |
342 | 347 | } |
343 | 348 |
|
344 | 349 | #pragma mark - NURLConnection delegate |
345 | 350 |
|
| 351 | +#if RETRIEVE_SSL_CERTIFICATES |
346 | 352 | - (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse |
347 | 353 | { |
348 | 354 | return cachedResponse; |
@@ -373,25 +379,24 @@ - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectio |
373 | 379 |
|
374 | 380 | - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge; |
375 | 381 | { |
376 | | -#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 |
377 | 382 | SecTrustRef trustRef = [[challenge protectionSpace] serverTrust]; |
378 | 383 | SecTrustResultType resultType; |
379 | 384 | 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]; |
383 | 388 | CFIndex idx; |
384 | 389 | for (idx = 0; idx < count; idx++) { |
385 | 390 | SecCertificateRef certificateRef = SecTrustGetCertificateAtIndex(trustRef, idx); |
386 | 391 | [certificates addObject:(id)certificateRef]; |
387 | 392 | } |
388 | | - |
| 393 | + |
389 | 394 | NSURLRequest *request = [[self connectionsToRequests] objectForKey:connection]; |
390 | 395 | NSURL *URL = [request URL]; |
391 | 396 | NSString *host = [URL host]; |
392 | 397 | [[self hostCertificates] setObject:certificates forKey:host]; |
393 | | -#endif |
394 | 398 | } |
| 399 | +#endif |
395 | 400 |
|
396 | 401 |
|
397 | 402 | - (void)dealloc |
|
0 commit comments