I extend this post with the method that I override of the webview, and that is missing in the previous code:
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
let method = challenge.protectionSpace.authenticationMethod
switch method {
case NSURLAuthenticationMethodClientCertificate:
sendClientCertificate(for: challenge, via: completionHandler)
default:
completionHandler(.performDefaultHandling, .none)
}
}