Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Unified Diff: ios/web/net/crw_cert_verification_controller_unittest.mm

Issue 2864133002: Convert iOS to use X509CertificateBytes. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/web/net/crw_cert_verification_controller_unittest.mm
diff --git a/ios/web/net/crw_cert_verification_controller_unittest.mm b/ios/web/net/crw_cert_verification_controller_unittest.mm
index aac4d43d3e1d33465b1e094c5f98d14b6dfdabf4..e49490fb6b5e33a00e3fa9cd100972c0e2808923 100644
--- a/ios/web/net/crw_cert_verification_controller_unittest.mm
+++ b/ios/web/net/crw_cert_verification_controller_unittest.mm
@@ -12,6 +12,7 @@
#include "ios/web/public/web_thread.h"
#import "ios/web/web_state/wk_web_view_security_util.h"
#include "net/cert/x509_certificate.h"
+#include "net/cert/x509_util_ios_and_mac.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
@@ -36,20 +37,15 @@ class CRWCertVerificationControllerTest : public web::WebTest {
net::ImportCertFromFile(net::GetTestCertsDirectory(), kCertFileName);
ASSERT_TRUE(cert_);
- NSArray* chain = GetChain(cert_);
- valid_trust_ = web::CreateServerTrustFromChain(chain, kHostName);
+ base::ScopedCFTypeRef<CFMutableArrayRef> chain(
+ net::x509_util::CreateSecCertificateArrayForX509Certificate(
+ cert_.get()));
+ ASSERT_TRUE(chain);
+ valid_trust_ = web::CreateServerTrustFromChain(
+ (__bridge NSArray*)chain.get(), kHostName);
Eugene But (OOO till 7-30) 2017/05/11 20:40:34 Should this be static_cast or reinterpret_cast ?
mattm 2017/05/12 01:04:15 I'm not really that familiar with all this, I was
Eugene But (OOO till 7-30) 2017/05/12 01:12:37 C-style casting is disallowed by Style Guide: http
mattm 2017/05/16 01:27:19 Ok, I guess static_cast works here since this file
web::EnsureFutureTrustEvaluationSucceeds(valid_trust_.get());
- invalid_trust_ = web::CreateServerTrustFromChain(chain, kHostName);
- }
-
- // Returns NSArray of SecCertificateRef objects for the given |cert|.
- NSArray* GetChain(const scoped_refptr<net::X509Certificate>& cert) const {
- NSMutableArray* result = [NSMutableArray
- arrayWithObject:static_cast<id>(cert->os_cert_handle())];
- for (SecCertificateRef intermediate : cert->GetIntermediateCertificates()) {
- [result addObject:static_cast<id>(intermediate)];
- }
- return result;
+ invalid_trust_ = web::CreateServerTrustFromChain(
+ (__bridge NSArray*)chain.get(), kHostName);
}
// Synchronously returns result of

Powered by Google App Engine
This is Rietveld 408576698