iOS - Load client certificate from local storage

This commit is contained in:
Lorenzo Pichilli 2022-10-13 17:44:07 +02:00
parent 0a49c7094f
commit 23d57ed807
1 changed files with 12 additions and 14 deletions

View File

@ -1993,11 +1993,13 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
let certificatePath = response.certificatePath
let certificatePassword = response.certificatePassword ?? "";
var path: String = certificatePath
do {
let path = try Util.getAbsPathAsset(assetFilePath: certificatePath)
let PKCS12Data = NSData(contentsOfFile: path)!
path = try Util.getAbsPathAsset(assetFilePath: certificatePath)
} catch {}
if let identityAndTrust: IdentityAndTrust = self.extractIdentity(PKCS12Data: PKCS12Data, password: certificatePassword) {
if let PKCS12Data = NSData(contentsOfFile: path),
let identityAndTrust: IdentityAndTrust = self.extractIdentity(PKCS12Data: PKCS12Data, password: certificatePassword) {
let urlCredential: URLCredential = URLCredential(
identity: identityAndTrust.identityRef,
certificates: identityAndTrust.certArray as? [AnyObject],
@ -2006,10 +2008,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
} else {
completionHandler(.performDefaultHandling, nil)
}
} catch {
print(error.localizedDescription)
completionHandler(.performDefaultHandling, nil)
}
break
case 2: