| 
				
			 | 
			
			
				@@ -16,6 +16,7 @@ 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				16
			 | 
			
			
				 static NSTimer *keyboardTimer; 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				17
			 | 
			
			
				 static NSString *const MessageHandlerName = @"ReactNativeWebView"; 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				18
			 | 
			
			
				 static NSURLCredential* clientAuthenticationCredential; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+static NSDictionary* customCertificatesForHost; 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				20
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				20
			 | 
			
				21
			 | 
			
			
				 // runtime trick to remove WKWebView keyboard default toolbar 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				22
			 | 
			
			
				 // see: http://stackoverflow.com/questions/19033292/ios-7-uiwebview-keyboard-issue/19042279#19042279 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -646,19 +647,44 @@ static NSURLCredential* clientAuthenticationCredential; 
			 | 
		
	
		
			
			| 
				646
			 | 
			
				647
			 | 
			
			
				   clientAuthenticationCredential = credential; 
			 | 
		
	
		
			
			| 
				647
			 | 
			
				648
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				648
			 | 
			
				649
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				650
			 | 
			
			
				++ (void)setCustomCertificatesForHost:(nullable NSDictionary*)certificates { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				651
			 | 
			
			
				+    customCertificatesForHost = certificates; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				652
			 | 
			
			
				+} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				653
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				649
			 | 
			
				654
			 | 
			
			
				 - (void)                    webView:(WKWebView *)webView 
			 | 
		
	
		
			
			| 
				650
			 | 
			
				655
			 | 
			
			
				   didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge 
			 | 
		
	
		
			
			| 
				651
			 | 
			
				656
			 | 
			
			
				                   completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable))completionHandler 
			 | 
		
	
		
			
			| 
				652
			 | 
			
				657
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				653
			 | 
			
				
			 | 
			
			
				-  if (!clientAuthenticationCredential) { 
			 | 
		
	
		
			
			| 
				654
			 | 
			
				
			 | 
			
			
				-    completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); 
			 | 
		
	
		
			
			| 
				655
			 | 
			
				
			 | 
			
			
				-    return; 
			 | 
		
	
		
			
			| 
				656
			 | 
			
				
			 | 
			
			
				-  } 
			 | 
		
	
		
			
			| 
				657
			 | 
			
				
			 | 
			
			
				-  if ([[challenge protectionSpace] authenticationMethod] == NSURLAuthenticationMethodClientCertificate) { 
			 | 
		
	
		
			
			| 
				658
			 | 
			
				
			 | 
			
			
				-    completionHandler(NSURLSessionAuthChallengeUseCredential, clientAuthenticationCredential); 
			 | 
		
	
		
			
			| 
				659
			 | 
			
				
			 | 
			
			
				-  } else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				658
			 | 
			
			
				+    NSString* host = nil; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				659
			 | 
			
			
				+    if (webView.URL != nil) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				660
			 | 
			
			
				+        host = webView.URL.host; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				661
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				662
			 | 
			
			
				+    if ([[challenge protectionSpace] authenticationMethod] == NSURLAuthenticationMethodClientCertificate) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				663
			 | 
			
			
				+        completionHandler(NSURLSessionAuthChallengeUseCredential, clientAuthenticationCredential); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				664
			 | 
			
			
				+        return; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				665
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				666
			 | 
			
			
				+    if ([[challenge protectionSpace] serverTrust] != nil && customCertificatesForHost != nil && host != nil) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				667
			 | 
			
			
				+        SecCertificateRef localCertificate = (__bridge SecCertificateRef)([customCertificatesForHost objectForKey:host]); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				668
			 | 
			
			
				+        if (localCertificate != nil) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				669
			 | 
			
			
				+            NSData *localCertificateData = (NSData*) CFBridgingRelease(SecCertificateCopyData(localCertificate)); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				670
			 | 
			
			
				+            SecTrustRef trust = [[challenge protectionSpace] serverTrust]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				671
			 | 
			
			
				+            long count = SecTrustGetCertificateCount(trust); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				672
			 | 
			
			
				+            for (long i = 0; i < count; i++) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				673
			 | 
			
			
				+                SecCertificateRef serverCertificate = SecTrustGetCertificateAtIndex(trust, i); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				674
			 | 
			
			
				+                if (serverCertificate == nil) { continue; } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				675
			 | 
			
			
				+                NSData *serverCertificateData = (NSData *) CFBridgingRelease(SecCertificateCopyData(serverCertificate)); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				676
			 | 
			
			
				+                if ([serverCertificateData isEqualToData:localCertificateData]) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				677
			 | 
			
			
				+                    NSURLCredential *useCredential = [NSURLCredential credentialForTrust:trust]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				678
			 | 
			
			
				+                    if (challenge.sender != nil) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				679
			 | 
			
			
				+                        [challenge.sender useCredential:useCredential forAuthenticationChallenge:challenge]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				680
			 | 
			
			
				+                    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				681
			 | 
			
			
				+                    completionHandler(NSURLSessionAuthChallengeUseCredential, useCredential); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				682
			 | 
			
			
				+                    return; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				683
			 | 
			
			
				+                } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				684
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				685
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				686
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				660
			 | 
			
				687
			 | 
			
			
				     completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); 
			 | 
		
	
		
			
			| 
				661
			 | 
			
				
			 | 
			
			
				-  } 
			 | 
		
	
		
			
			| 
				662
			 | 
			
				688
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				663
			 | 
			
				689
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				664
			 | 
			
				690
			 | 
			
			
				 #pragma mark - WKNavigationDelegate methods 
			 |