webview 에서 서버와 통신시 서버 인증서가 만료 되었는지 확인하는 코드
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
{
SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
CFDataRef exceptions = SecTrustCopyExceptions(serverTrust);
SecTrustSetExceptions (serverTrust, exceptions);
CFDictionaryRef currentListingRef = SecTrustCopyResult(serverTrust);
NSDictionary *test = CFBridgingRelease(currentListingRef);
CFRelease(exceptions);
completionHandler (NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:serverTrust]);
}
test 변수 에서 TrustExpirationDate 를 체크하면 된다.