Skip to content

Commit

Permalink
fix(webview): authenticationMethod NSURLAuthenticationMethodClientCer…
Browse files Browse the repository at this point in the history
…tificate not handled correctly (#13352)
  • Loading branch information
chauf committed Apr 1, 2022
1 parent 498b596 commit edfd037
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,13 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
}
// HTTPS in general
} else if ([authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
} else if ([authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]
|| [authenticationMethod isEqualToString:NSURLAuthenticationMethodClientCertificate]) {
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
// Default: Reject authentication challenge
} else {
// Not sure why not let the DefaultHandling handle this but at least warn in the log because of canceled challenge
NSLog(@"[WARN] Ti.UI.WebView canceled unknown authentication challenge with method %@", authenticationMethod);
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/Resources/ti.ui.webview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,4 +950,24 @@ describe('Titanium.UI.WebView', function () {
win.open();
});
});

it('url with clientCertChallenge', function (finish) {
const url = 'https://device.login.microsoftonline.com';

win = Ti.UI.createWindow();
const webView = Ti.UI.createWebView({
url: url
});

webView.addEventListener('error', function () {
finish(new Error('clientCertChallenge must be handled correctly.'));
});

webView.addEventListener('load', function () {
finish();
});

win.add(webView);
win.open();
});
});

0 comments on commit edfd037

Please sign in to comment.