iOS - Load client certificate from local storage
This commit is contained in:
parent
0a49c7094f
commit
23d57ed807
|
@ -1993,21 +1993,19 @@ 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) {
|
||||
let urlCredential: URLCredential = URLCredential(
|
||||
identity: identityAndTrust.identityRef,
|
||||
certificates: identityAndTrust.certArray as? [AnyObject],
|
||||
persistence: URLCredential.Persistence.forSession);
|
||||
completionHandler(.useCredential, urlCredential)
|
||||
} else {
|
||||
completionHandler(.performDefaultHandling, nil)
|
||||
}
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
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],
|
||||
persistence: URLCredential.Persistence.forSession);
|
||||
completionHandler(.useCredential, urlCredential)
|
||||
} else {
|
||||
completionHandler(.performDefaultHandling, nil)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue