を使用NSURLConnection
してワイルドカード TLS 証明書 (「*.domain.com」など) を使用してサーバーに接続していますが、 のメソッドを呼び出すとSecTrustEvaluate
、NSURLConnectionDelegate
証明-connection:willSendRequestForAuthenticationChallenge:
書が無効として拒否されます。完全に指定された TLS 証明書 (「server2.domain.com」など) を持つ別のサーバーが受け入れられます。どちらの証明書も同じ CA によって発行されており、CA 証明書をデバイスの信頼できる証明書リストに追加しました。
iPhone / iOS 8.1 の Safari から同じ動作が見られます。ワイルドカード証明書を持つサーバーは、信頼されていない証明書を持っていると報告されますが、他のサーバーは正常に動作します。そのため、iOS のデフォルトの証明書検証はワイルドカード証明書を拒否しているようです。これは事実ですか?
SecEvaluateTrust
ワイルドカード証明書を許可するように指示する方法はありますか? これが私の抜粋です-connection:willSendRequestForAuthenticationChallenge:
- (void)connection:(NSURLConnection *)connection
willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod
isEqualToString:NSURLAuthenticationMethodServerTrust]) {
SecTrustRef trust = [challenge.protectionSpace serverTrust];
SecTrustResultType trustResult;
OSStatus status = SecTrustEvaluate(trust, &trustResult);
if (status == noErr) {
if (trustResult == kSecTrustResultProceed
|| trustResult == kSecTrustResultUnspecified) {
// Success. server2 gets here
} else {
// Server authentication failure. server1 gets here
}
}
}
}
編集私たちのソフトウェアの Android バージョンはワイルドカード証明書を問題なく受け入れるので、ここで行われている iOS の証明書処理に固有の何かがあるのではないかと思います。Android クライアントはBrowserCompatHostnameVerifier
、証明書を検証するために使用しています。これは、私が理解している限りSecPolicyCreateSSL
、ブラウザーと同じ証明書のチェックを実行するのと同じ機能を実行します。