Skip to content

Commit f818777

Browse files
author
Lars Steiger
committed
Merge branch 'bug-13'
2 parents 2025e5a + b921409 commit f818777

File tree

2 files changed

+14
-77
lines changed

2 files changed

+14
-77
lines changed

FsprgEmbeddedStore/FsprgEmbeddedStoreController.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
id <FsprgEmbeddedStoreDelegate> delegate;
2020
NSString *storeHost;
2121
NSMutableDictionary *hostCertificates;
22-
NSMapTable *connectionsToRequests;
2322
}
2423

2524
- (WebView *)webView;

FsprgEmbeddedStore/FsprgEmbeddedStoreController.m

Lines changed: 14 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ - (void)resizeContentDivE;
2424
- (void)webViewFrameChanged:(NSNotification *)aNotification;
2525
- (NSMutableDictionary *)hostCertificates;
2626
- (void)setHostCertificates:(NSMutableDictionary *)aHostCertificates;
27-
- (NSMapTable *)connectionsToRequests;
28-
- (void)setConnectionsToRequests:(NSMapTable *)aConnectionsToRequests;
2927

3028
@end
3129

@@ -47,11 +45,6 @@ - (id) init
4745
[self setDelegate:nil];
4846
[self setStoreHost:nil];
4947
[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
5548
}
5649
return self;
5750
}
@@ -242,19 +235,6 @@ - (void)setHostCertificates:(NSMutableDictionary *)anHostCertificates
242235
}
243236
}
244237

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-
258238

259239
#pragma mark - WebFrameLoadDelegate
260240

@@ -332,69 +312,28 @@ - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)
332312

333313
#pragma mark - WebResourceLoadDelegate
334314

335-
- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
336-
{
337315
#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
362317
{
318+
return TRUE;
363319
}
364320

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
366322
{
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);
386327

387328
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+
}
393334

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];
398337

399338
[[challenge sender] useCredential:[NSURLCredential credentialForTrust:trustRef] forAuthenticationChallenge:challenge];
400339
}
@@ -407,7 +346,6 @@ - (void)dealloc
407346
[self setDelegate:nil];
408347
[self setStoreHost:nil];
409348
[self setHostCertificates:nil];
410-
[self setConnectionsToRequests:nil];
411349

412350
[super dealloc];
413351
}

0 commit comments

Comments
 (0)