@@ -24,8 +24,6 @@ - (void)resizeContentDivE;
24
24
- (void )webViewFrameChanged:(NSNotification *)aNotification;
25
25
- (NSMutableDictionary *)hostCertificates;
26
26
- (void )setHostCertificates:(NSMutableDictionary *)aHostCertificates;
27
- - (NSMapTable *)connectionsToRequests;
28
- - (void )setConnectionsToRequests:(NSMapTable *)aConnectionsToRequests;
29
27
30
28
@end
31
29
@@ -47,11 +45,6 @@ - (id) init
47
45
[self setDelegate: nil ];
48
46
[self setStoreHost: nil ];
49
47
[self setHostCertificates: [NSMutableDictionary dictionary ]];
50
- #if defined(MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
51
- [self setConnectionsToRequests: [NSMapTable strongToStrongObjectsMapTable ]];
52
- #else
53
- [self setConnectionsToRequests: [NSMapTable mapTableWithStrongToStrongObjects ]];
54
- #endif
55
48
}
56
49
return self;
57
50
}
@@ -242,19 +235,6 @@ - (void)setHostCertificates:(NSMutableDictionary *)anHostCertificates
242
235
}
243
236
}
244
237
245
- - (NSMapTable *)connectionsToRequests
246
- {
247
- return [[connectionsToRequests retain ] autorelease ];
248
- }
249
- - (void )setConnectionsToRequests : (NSMapTable *)aConnectionsToRequests
250
- {
251
- if (connectionsToRequests != aConnectionsToRequests) {
252
- [aConnectionsToRequests retain ];
253
- [connectionsToRequests release ];
254
- connectionsToRequests = aConnectionsToRequests;
255
- }
256
- }
257
-
258
238
259
239
#pragma mark - WebFrameLoadDelegate
260
240
@@ -332,69 +312,28 @@ - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)
332
312
333
313
#pragma mark - WebResourceLoadDelegate
334
314
335
- - (NSURLRequest *)webView : (WebView *)sender resource : (id )identifier willSendRequest : (NSURLRequest *)request redirectResponse : (NSURLResponse *)redirectResponse fromDataSource : (WebDataSource *)dataSource
336
- {
337
315
#if RETRIEVE_SSL_CERTIFICATES
338
- NSURL *URL = [request URL ];
339
- NSString *host = [URL host ];
340
- if ([[self hostCertificates ] objectForKey: host] == nil )
341
- {
342
- NSURLConnection *connection = [[[NSURLConnection alloc ] initWithRequest: request delegate: self ] autorelease ];
343
- [[self connectionsToRequests ] setObject: request forKey: connection];
344
- }
345
- #endif
346
- return request;
347
- }
348
-
349
- #pragma mark - NURLConnection delegate
350
-
351
- #if RETRIEVE_SSL_CERTIFICATES
352
- - (NSCachedURLResponse *)connection : (NSURLConnection *)connection willCacheResponse : (NSCachedURLResponse *)cachedResponse
353
- {
354
- return cachedResponse;
355
- }
356
-
357
- - (void )connection : (NSURLConnection *)connection didReceiveResponse : (NSURLResponse *)response
358
- {
359
- }
360
-
361
- - (void )connection : (NSURLConnection *)connection didReceiveData : (NSData *)data
316
+ - (BOOL )webView : (WebView *)sender resource : (id )identifier canAuthenticateAgainstProtectionSpace : (NSURLProtectionSpace *)protectionSpace forDataSource : (WebDataSource *)dataSource
362
317
{
318
+ return TRUE ;
363
319
}
364
320
365
- - (NSURLRequest *) connection : ( NSURLConnection *)connection willSendRequest : ( NSURLRequest *) request redirectResponse : ( NSURLResponse *)redirectResponse
321
+ - (void ) webView : ( WebView *)sender resource : ( id ) identifier didReceiveAuthenticationChallenge : ( NSURLAuthenticationChallenge *) challenge fromDataSource : ( WebDataSource *)dataSource
366
322
{
367
- return request;
368
- }
369
-
370
- - (void )connectionDidFinishLoading : (NSURLConnection *)connection
371
- {
372
- [[self connectionsToRequests ] setObject: nil forKey: connection];
373
- }
374
-
375
- - (BOOL )connection : (NSURLConnection *)connection canAuthenticateAgainstProtectionSpace : (NSURLProtectionSpace *)protectionSpace
376
- {
377
- return YES ;
378
- }
379
-
380
- - (void )connection : (NSURLConnection *)connection didReceiveAuthenticationChallenge : (NSURLAuthenticationChallenge *)challenge ;
381
- {
382
- SecTrustRef trustRef = [[challenge protectionSpace ] serverTrust ];
383
- SecTrustResultType resultType;
384
- SecTrustEvaluate (trustRef, &resultType);
385
- NSUInteger count = (NSUInteger )SecTrustGetCertificateCount (trustRef);
323
+ SecTrustRef trustRef = [[challenge protectionSpace ] serverTrust ];
324
+ SecTrustResultType resultType;
325
+ SecTrustEvaluate (trustRef, &resultType);
326
+ NSUInteger count = (NSUInteger )SecTrustGetCertificateCount (trustRef);
386
327
387
328
NSMutableArray *certificates = [NSMutableArray arrayWithCapacity: count];
388
- CFIndex idx;
389
- for (idx = 0 ; idx < (CFIndex)count; idx++) {
390
- SecCertificateRef certificateRef = SecTrustGetCertificateAtIndex (trustRef, idx);
391
- [certificates addObject: (id )certificateRef];
392
- }
329
+ CFIndex idx;
330
+ for (idx = 0 ; idx < (CFIndex)count; idx++) {
331
+ SecCertificateRef certificateRef = SecTrustGetCertificateAtIndex (trustRef, idx);
332
+ [certificates addObject: (id )certificateRef];
333
+ }
393
334
394
- NSURLRequest *request = [[self connectionsToRequests ] objectForKey: connection];
395
- NSURL *URL = [request URL ];
396
- NSString *host = [URL host ];
397
- [[self hostCertificates ] setObject: certificates forKey: host];
335
+ NSString *host = [[challenge protectionSpace ] host ];
336
+ [[self hostCertificates ] setObject: certificates forKey: host];
398
337
399
338
[[challenge sender ] useCredential: [NSURLCredential credentialForTrust: trustRef] forAuthenticationChallenge: challenge];
400
339
}
@@ -407,7 +346,6 @@ - (void)dealloc
407
346
[self setDelegate: nil ];
408
347
[self setStoreHost: nil ];
409
348
[self setHostCertificates: nil ];
410
- [self setConnectionsToRequests: nil ];
411
349
412
350
[super dealloc ];
413
351
}
0 commit comments