Post not yet marked as solved
Post marked as unsolved with 6 replies, 1,014 views
Hi,
I implemented the NSPinnedDomains according to https://developer.apple.com/news/?id=g9ejcf8y "Identity Pinning: How to configure server certificates for your app".
This is my config (I added a wrong SHA256 hash so I can test if it works):
keyNSAppTransportSecurity/key
dict
keyNSPinnedDomains/key
dict
keyjsonplaceholder.typicode.com/key
dict
keyNSPinnedCAIdentities/key
array
dict
keySPKI-SHA256-BASE64/key
stringr/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=/string
/dict
/array
keyNSIncludesSubdomains/key
true/
/dict
/dict
/dict
With NSURLSessions it properly fails when I try to load https://jsonplaceholder.typicode.com/todos/2
it prints following error:
An SSL error has occurred and a secure connection to the server cannot be made
But when I try to load the URL from JavaScript in WKWebView, it succeeds.
Is WKWebView not supported? Or am I doing something wrong?
Thanks and kind regards,
Mika
Objc code:
NSString *urlString = @"https://jsonplaceholder.typicode.com/todos/2";
NSURL *url = [NSURL URLWithString:urlString];
NSURLSessionDataTask *downloadTask = [[NSURLSession sharedSession]
dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
}];
[downloadTask resume];
Web code (can be included in any html page inside WKWebView):
script
document.addEventListener("DOMContentLoaded", () = {
fetch("https://jsonplaceholder.typicode.com/todos/2")
.then(res = res.json())
.then(res = console.log(res));
});
/script