Skip to content

Commit

Permalink
client certificate authentication (#1)
Browse files Browse the repository at this point in the history
using cordova-plugin-client-certificate-support with this proposal:

- cordova-ccafix/cordova-plugin-client-certificate-support#12
  • Loading branch information
Chris Brody authored Jan 17, 2022
1 parent f7aad2b commit afac9bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/ios/CDVWKWebViewFileXhr.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#import "CDVWKWebViewFileXhr.h"
#import <Cordova/CDV.h>

#import "ClientCertificate.h"

NS_ASSUME_NONNULL_BEGIN


Expand Down Expand Up @@ -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");
}


Expand Down

0 comments on commit afac9bb

Please sign in to comment.