From afac9bb95673c18332ca4bcf632d78c470349306 Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Sun, 16 Jan 2022 20:52:05 -0500 Subject: [PATCH] client certificate authentication (#1) using cordova-plugin-client-certificate-support with this proposal: - https://github.com/cordova-ccafix/cordova-plugin-client-certificate-support/pull/12 --- src/ios/CDVWKWebViewFileXhr.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVWKWebViewFileXhr.m b/src/ios/CDVWKWebViewFileXhr.m index 68fdf24..acec5d7 100644 --- a/src/ios/CDVWKWebViewFileXhr.m +++ b/src/ios/CDVWKWebViewFileXhr.m @@ -35,6 +35,8 @@ #import "CDVWKWebViewFileXhr.h" #import +#import "ClientCertificate.h" + NS_ASSUME_NONNULL_BEGIN @@ -314,19 +316,22 @@ - (void)getConfig:(CDVInvokedUrlCommand*)command { - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler { - + // --- + NSLog(@"URL session auth challenge"); if (_allowsInsecureLoads) { SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; if (serverTrust) { CFDataRef exceptions = SecTrustCopyExceptions (serverTrust); SecTrustSetExceptions (serverTrust, exceptions); CFRelease (exceptions); + NSLog(@"FINISH URL session auth challenge with credential from server trust"); completionHandler (NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:serverTrust]); // FortityFalsePositive return; } } - completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + [ClientCertificate didReceiveAuthenticationChallenge:challenge completionHandler:completionHandler withOptionsNullable:nil]; + NSLog(@"FINISHED URL session auth challenge callback"); }