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

Side by Side Diff: net/base/x509_certificate_unittest.cc

Issue 7819009: For the SSL cert status, convert anonymous enum that gives bit values into a typedefed uint32. Th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 #include "base/sha1.h" 9 #include "base/sha1.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 google_cert->GetDNSNames(&dns_names); 224 google_cert->GetDNSNames(&dns_names);
225 ASSERT_EQ(1U, dns_names.size()); 225 ASSERT_EQ(1U, dns_names.size());
226 EXPECT_EQ("www.google.com", dns_names[0]); 226 EXPECT_EQ("www.google.com", dns_names[0]);
227 227
228 #if TEST_EV 228 #if TEST_EV
229 // TODO(avi): turn this on for the Mac once EV checking is implemented. 229 // TODO(avi): turn this on for the Mac once EV checking is implemented.
230 CertVerifyResult verify_result; 230 CertVerifyResult verify_result;
231 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED | 231 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED |
232 X509Certificate::VERIFY_EV_CERT; 232 X509Certificate::VERIFY_EV_CERT;
233 EXPECT_EQ(OK, google_cert->Verify("www.google.com", flags, &verify_result)); 233 EXPECT_EQ(OK, google_cert->Verify("www.google.com", flags, &verify_result));
234 EXPECT_EQ(0, verify_result.cert_status & CERT_STATUS_IS_EV); 234 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_IS_EV);
235 #endif 235 #endif
236 } 236 }
237 237
238 TEST(X509CertificateTest, GoogleCertParsing) { 238 TEST(X509CertificateTest, GoogleCertParsing) {
239 scoped_refptr<X509Certificate> google_cert( 239 scoped_refptr<X509Certificate> google_cert(
240 X509Certificate::CreateFromBytes( 240 X509Certificate::CreateFromBytes(
241 reinterpret_cast<const char*>(google_der), sizeof(google_der))); 241 reinterpret_cast<const char*>(google_der), sizeof(google_der)));
242 242
243 CheckGoogleCert(google_cert, google_fingerprint, 243 CheckGoogleCert(google_cert, google_fingerprint,
244 1238192407, // Mar 27 22:20:07 2009 GMT 244 1238192407, // Mar 27 22:20:07 2009 GMT
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 webkit_cert->GetDNSNames(&dns_names); 290 webkit_cert->GetDNSNames(&dns_names);
291 ASSERT_EQ(2U, dns_names.size()); 291 ASSERT_EQ(2U, dns_names.size());
292 EXPECT_EQ("*.webkit.org", dns_names[0]); 292 EXPECT_EQ("*.webkit.org", dns_names[0]);
293 EXPECT_EQ("webkit.org", dns_names[1]); 293 EXPECT_EQ("webkit.org", dns_names[1]);
294 294
295 #if TEST_EV 295 #if TEST_EV
296 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED | 296 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED |
297 X509Certificate::VERIFY_EV_CERT; 297 X509Certificate::VERIFY_EV_CERT;
298 CertVerifyResult verify_result; 298 CertVerifyResult verify_result;
299 EXPECT_EQ(OK, webkit_cert->Verify("webkit.org", flags, &verify_result)); 299 EXPECT_EQ(OK, webkit_cert->Verify("webkit.org", flags, &verify_result));
300 EXPECT_EQ(0, verify_result.cert_status & CERT_STATUS_IS_EV); 300 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_IS_EV);
301 #endif 301 #endif
302 302
303 // Test that the wildcard cert matches properly. 303 // Test that the wildcard cert matches properly.
304 EXPECT_TRUE(webkit_cert->VerifyNameMatch("www.webkit.org")); 304 EXPECT_TRUE(webkit_cert->VerifyNameMatch("www.webkit.org"));
305 EXPECT_TRUE(webkit_cert->VerifyNameMatch("foo.webkit.org")); 305 EXPECT_TRUE(webkit_cert->VerifyNameMatch("foo.webkit.org"));
306 EXPECT_TRUE(webkit_cert->VerifyNameMatch("webkit.org")); 306 EXPECT_TRUE(webkit_cert->VerifyNameMatch("webkit.org"));
307 EXPECT_FALSE(webkit_cert->VerifyNameMatch("www.webkit.com")); 307 EXPECT_FALSE(webkit_cert->VerifyNameMatch("www.webkit.com"));
308 EXPECT_FALSE(webkit_cert->VerifyNameMatch("www.foo.webkit.com")); 308 EXPECT_FALSE(webkit_cert->VerifyNameMatch("www.foo.webkit.com"));
309 } 309 }
310 310
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 thawte_cert->GetDNSNames(&dns_names); 353 thawte_cert->GetDNSNames(&dns_names);
354 ASSERT_EQ(1U, dns_names.size()); 354 ASSERT_EQ(1U, dns_names.size());
355 EXPECT_EQ("www.thawte.com", dns_names[0]); 355 EXPECT_EQ("www.thawte.com", dns_names[0]);
356 356
357 #if TEST_EV 357 #if TEST_EV
358 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED | 358 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED |
359 X509Certificate::VERIFY_EV_CERT; 359 X509Certificate::VERIFY_EV_CERT;
360 CertVerifyResult verify_result; 360 CertVerifyResult verify_result;
361 // EV cert verification requires revocation checking. 361 // EV cert verification requires revocation checking.
362 EXPECT_EQ(OK, thawte_cert->Verify("www.thawte.com", flags, &verify_result)); 362 EXPECT_EQ(OK, thawte_cert->Verify("www.thawte.com", flags, &verify_result));
363 EXPECT_NE(0, verify_result.cert_status & CERT_STATUS_IS_EV); 363 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV);
364 // Consequently, if we don't have revocation checking enabled, we can't claim 364 // Consequently, if we don't have revocation checking enabled, we can't claim
365 // any cert is EV. 365 // any cert is EV.
366 flags = X509Certificate::VERIFY_EV_CERT; 366 flags = X509Certificate::VERIFY_EV_CERT;
367 EXPECT_EQ(OK, thawte_cert->Verify("www.thawte.com", flags, &verify_result)); 367 EXPECT_EQ(OK, thawte_cert->Verify("www.thawte.com", flags, &verify_result));
368 EXPECT_EQ(0, verify_result.cert_status & CERT_STATUS_IS_EV); 368 EXPECT_FALSE(verify_result.cert_status & CERT_STATUS_IS_EV);
369 #endif 369 #endif
370 } 370 }
371 371
372 TEST(X509CertificateTest, PaypalNullCertParsing) { 372 TEST(X509CertificateTest, PaypalNullCertParsing) {
373 scoped_refptr<X509Certificate> paypal_null_cert( 373 scoped_refptr<X509Certificate> paypal_null_cert(
374 X509Certificate::CreateFromBytes( 374 X509Certificate::CreateFromBytes(
375 reinterpret_cast<const char*>(paypal_null_der), 375 reinterpret_cast<const char*>(paypal_null_der),
376 sizeof(paypal_null_der))); 376 sizeof(paypal_null_der)));
377 377
378 ASSERT_NE(static_cast<X509Certificate*>(NULL), paypal_null_cert); 378 ASSERT_NE(static_cast<X509Certificate*>(NULL), paypal_null_cert);
(...skipping 11 matching lines...) Expand all
390 // TOOD(bulach): investigate why macosx and win aren't returning 390 // TOOD(bulach): investigate why macosx and win aren't returning
391 // ERR_CERT_INVALID or ERR_CERT_COMMON_NAME_INVALID. 391 // ERR_CERT_INVALID or ERR_CERT_COMMON_NAME_INVALID.
392 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error); 392 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error);
393 #else 393 #else
394 EXPECT_EQ(ERR_CERT_COMMON_NAME_INVALID, error); 394 EXPECT_EQ(ERR_CERT_COMMON_NAME_INVALID, error);
395 #endif 395 #endif
396 // Either the system crypto library should correctly report a certificate 396 // Either the system crypto library should correctly report a certificate
397 // name mismatch, or our certificate blacklist should cause us to report an 397 // name mismatch, or our certificate blacklist should cause us to report an
398 // invalid certificate. 398 // invalid certificate.
399 #if !defined(OS_MACOSX) && !defined(USE_OPENSSL) 399 #if !defined(OS_MACOSX) && !defined(USE_OPENSSL)
400 EXPECT_NE(0, verify_result.cert_status & 400 EXPECT_TRUE(verify_result.cert_status &
401 (CERT_STATUS_COMMON_NAME_INVALID | CERT_STATUS_INVALID)); 401 (CERT_STATUS_COMMON_NAME_INVALID | CERT_STATUS_INVALID));
402 #endif 402 #endif
403 } 403 }
404 404
405 // A certificate whose AIA extension contains an LDAP URL without a host name. 405 // A certificate whose AIA extension contains an LDAP URL without a host name.
406 // This certificate will expire on 2011-09-08. 406 // This certificate will expire on 2011-09-08.
407 TEST(X509CertificateTest, UnoSoftCertParsing) { 407 TEST(X509CertificateTest, UnoSoftCertParsing) {
408 FilePath certs_dir = GetTestCertsDirectory(); 408 FilePath certs_dir = GetTestCertsDirectory();
409 scoped_refptr<X509Certificate> unosoft_hu_cert( 409 scoped_refptr<X509Certificate> unosoft_hu_cert(
410 ImportCertFromFile(certs_dir, "unosoft_hu_cert.der")); 410 ImportCertFromFile(certs_dir, "unosoft_hu_cert.der"));
411 411
412 ASSERT_NE(static_cast<X509Certificate*>(NULL), unosoft_hu_cert); 412 ASSERT_NE(static_cast<X509Certificate*>(NULL), unosoft_hu_cert);
413 413
414 const SHA1Fingerprint& fingerprint = 414 const SHA1Fingerprint& fingerprint =
415 unosoft_hu_cert->fingerprint(); 415 unosoft_hu_cert->fingerprint();
416 for (size_t i = 0; i < 20; ++i) 416 for (size_t i = 0; i < 20; ++i)
417 EXPECT_EQ(unosoft_hu_fingerprint[i], fingerprint.data[i]); 417 EXPECT_EQ(unosoft_hu_fingerprint[i], fingerprint.data[i]);
418 418
419 int flags = 0; 419 int flags = 0;
420 CertVerifyResult verify_result; 420 CertVerifyResult verify_result;
421 int error = unosoft_hu_cert->Verify("www.unosoft.hu", flags, 421 int error = unosoft_hu_cert->Verify("www.unosoft.hu", flags,
422 &verify_result); 422 &verify_result);
423 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error); 423 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error);
424 EXPECT_NE(0, verify_result.cert_status & CERT_STATUS_AUTHORITY_INVALID); 424 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_AUTHORITY_INVALID);
425 } 425 }
426 426
427 TEST(X509CertificateTest, SerialNumbers) { 427 TEST(X509CertificateTest, SerialNumbers) {
428 scoped_refptr<X509Certificate> google_cert( 428 scoped_refptr<X509Certificate> google_cert(
429 X509Certificate::CreateFromBytes( 429 X509Certificate::CreateFromBytes(
430 reinterpret_cast<const char*>(google_der), sizeof(google_der))); 430 reinterpret_cast<const char*>(google_der), sizeof(google_der)));
431 431
432 static const uint8 google_serial[16] = { 432 static const uint8 google_serial[16] = {
433 0x01,0x2a,0x39,0x76,0x0d,0x3f,0x4f,0xc9, 433 0x01,0x2a,0x39,0x76,0x0d,0x3f,0x4f,0xc9,
434 0x0b,0xe7,0xbd,0x2b,0xcf,0x95,0x2e,0x7a, 434 0x0b,0xe7,0xbd,0x2b,0xcf,0x95,0x2e,0x7a,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 X509Certificate::OSCertHandles intermediates; 474 X509Certificate::OSCertHandles intermediates;
475 intermediates.push_back(intermediate_cert->os_cert_handle()); 475 intermediates.push_back(intermediate_cert->os_cert_handle());
476 scoped_refptr<X509Certificate> cert_chain = 476 scoped_refptr<X509Certificate> cert_chain =
477 X509Certificate::CreateFromHandle(server_cert->os_cert_handle(), 477 X509Certificate::CreateFromHandle(server_cert->os_cert_handle(),
478 intermediates); 478 intermediates);
479 479
480 int flags = 0; 480 int flags = 0;
481 CertVerifyResult verify_result; 481 CertVerifyResult verify_result;
482 int error = cert_chain->Verify("www.us.army.mil", flags, &verify_result); 482 int error = cert_chain->Verify("www.us.army.mil", flags, &verify_result);
483 EXPECT_EQ(OK, error); 483 EXPECT_EQ(OK, error);
484 EXPECT_EQ(0, verify_result.cert_status); 484 EXPECT_EQ(CERT_STATUS_NO_ERROR, verify_result.cert_status);
485 root_certs->Clear(); 485 root_certs->Clear();
486 } 486 }
487 487
488 // Test for bug 58437. 488 // Test for bug 58437.
489 // This certificate will expire on 2011-12-21. The test will still 489 // This certificate will expire on 2011-12-21. The test will still
490 // pass if error == ERR_CERT_DATE_INVALID. 490 // pass if error == ERR_CERT_DATE_INVALID.
491 // This test is DISABLED because it appears that we cannot do 491 // This test is DISABLED because it appears that we cannot do
492 // certificate revocation checking when running all of the net unit tests. 492 // certificate revocation checking when running all of the net unit tests.
493 // This test passes when run individually, but when run with all of the net 493 // This test passes when run individually, but when run with all of the net
494 // unit tests, the call to PKIXVerifyCert returns the NSS error -8180, which is 494 // unit tests, the call to PKIXVerifyCert returns the NSS error -8180, which is
(...skipping 14 matching lines...) Expand all
509 intermediates.push_back(intermediate_cert->os_cert_handle()); 509 intermediates.push_back(intermediate_cert->os_cert_handle());
510 scoped_refptr<X509Certificate> cert_chain = 510 scoped_refptr<X509Certificate> cert_chain =
511 X509Certificate::CreateFromHandle(server_cert->os_cert_handle(), 511 X509Certificate::CreateFromHandle(server_cert->os_cert_handle(),
512 intermediates); 512 intermediates);
513 513
514 CertVerifyResult verify_result; 514 CertVerifyResult verify_result;
515 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED | 515 int flags = X509Certificate::VERIFY_REV_CHECKING_ENABLED |
516 X509Certificate::VERIFY_EV_CERT; 516 X509Certificate::VERIFY_EV_CERT;
517 int error = cert_chain->Verify("2029.globalsign.com", flags, &verify_result); 517 int error = cert_chain->Verify("2029.globalsign.com", flags, &verify_result);
518 if (error == OK) 518 if (error == OK)
519 EXPECT_NE(0, verify_result.cert_status & CERT_STATUS_IS_EV); 519 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_IS_EV);
520 else 520 else
521 EXPECT_EQ(ERR_CERT_DATE_INVALID, error); 521 EXPECT_EQ(ERR_CERT_DATE_INVALID, error);
522 } 522 }
523 523
524 TEST(X509CertificateTest, TestKnownRoot) { 524 TEST(X509CertificateTest, TestKnownRoot) {
525 FilePath certs_dir = GetTestCertsDirectory(); 525 FilePath certs_dir = GetTestCertsDirectory();
526 scoped_refptr<X509Certificate> cert = 526 scoped_refptr<X509Certificate> cert =
527 ImportCertFromFile(certs_dir, "nist.der"); 527 ImportCertFromFile(certs_dir, "nist.der");
528 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert); 528 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert);
529 529
530 // This intermediate is only needed for old Linux machines. Modern NSS 530 // This intermediate is only needed for old Linux machines. Modern NSS
531 // includes it as a root already. 531 // includes it as a root already.
532 scoped_refptr<X509Certificate> intermediate_cert = 532 scoped_refptr<X509Certificate> intermediate_cert =
533 ImportCertFromFile(certs_dir, "nist_intermediate.der"); 533 ImportCertFromFile(certs_dir, "nist_intermediate.der");
534 ASSERT_NE(static_cast<X509Certificate*>(NULL), intermediate_cert); 534 ASSERT_NE(static_cast<X509Certificate*>(NULL), intermediate_cert);
535 535
536 X509Certificate::OSCertHandles intermediates; 536 X509Certificate::OSCertHandles intermediates;
537 intermediates.push_back(intermediate_cert->os_cert_handle()); 537 intermediates.push_back(intermediate_cert->os_cert_handle());
538 scoped_refptr<X509Certificate> cert_chain = 538 scoped_refptr<X509Certificate> cert_chain =
539 X509Certificate::CreateFromHandle(cert->os_cert_handle(), 539 X509Certificate::CreateFromHandle(cert->os_cert_handle(),
540 intermediates); 540 intermediates);
541 541
542 int flags = 0; 542 int flags = 0;
543 CertVerifyResult verify_result; 543 CertVerifyResult verify_result;
544 // This is going to blow up in Feb 2012. Sorry! Disable and file a bug 544 // This is going to blow up in Feb 2012. Sorry! Disable and file a bug
545 // against agl. Also see PublicKeyHashes in this file. 545 // against agl. Also see PublicKeyHashes in this file.
546 int error = cert_chain->Verify("www.nist.gov", flags, &verify_result); 546 int error = cert_chain->Verify("www.nist.gov", flags, &verify_result);
547 EXPECT_EQ(OK, error); 547 EXPECT_EQ(OK, error);
548 EXPECT_EQ(0, verify_result.cert_status); 548 EXPECT_EQ(CERT_STATUS_NO_ERROR, verify_result.cert_status);
549 EXPECT_TRUE(verify_result.is_issued_by_known_root); 549 EXPECT_TRUE(verify_result.is_issued_by_known_root);
550 } 550 }
551 551
552 // This is the SHA1 hash of the SubjectPublicKeyInfo of nist.der. 552 // This is the SHA1 hash of the SubjectPublicKeyInfo of nist.der.
553 static const char nistSPKIHash[] = 553 static const char nistSPKIHash[] =
554 "\x15\x60\xde\x65\x4e\x03\x9f\xd0\x08\x82" 554 "\x15\x60\xde\x65\x4e\x03\x9f\xd0\x08\x82"
555 "\xa9\x6a\xc4\x65\x8e\x6f\x92\x06\x84\x35"; 555 "\xa9\x6a\xc4\x65\x8e\x6f\x92\x06\x84\x35";
556 556
557 TEST(X509CertificateTest, ExtractSPKIFromDERCert) { 557 TEST(X509CertificateTest, ExtractSPKIFromDERCert) {
558 FilePath certs_dir = GetTestCertsDirectory(); 558 FilePath certs_dir = GetTestCertsDirectory();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 intermediates.push_back(intermediate_cert->os_cert_handle()); 612 intermediates.push_back(intermediate_cert->os_cert_handle());
613 scoped_refptr<X509Certificate> cert_chain = 613 scoped_refptr<X509Certificate> cert_chain =
614 X509Certificate::CreateFromHandle(cert->os_cert_handle(), 614 X509Certificate::CreateFromHandle(cert->os_cert_handle(),
615 intermediates); 615 intermediates);
616 616
617 int flags = 0; 617 int flags = 0;
618 CertVerifyResult verify_result; 618 CertVerifyResult verify_result;
619 619
620 int error = cert_chain->Verify("www.nist.gov", flags, &verify_result); 620 int error = cert_chain->Verify("www.nist.gov", flags, &verify_result);
621 EXPECT_EQ(OK, error); 621 EXPECT_EQ(OK, error);
622 EXPECT_EQ(0, verify_result.cert_status); 622 EXPECT_EQ(CERT_STATUS_NO_ERROR, verify_result.cert_status);
623 ASSERT_LE(2u, verify_result.public_key_hashes.size()); 623 ASSERT_LE(2u, verify_result.public_key_hashes.size());
624 EXPECT_EQ(HexEncode(nistSPKIHash, base::SHA1_LENGTH), 624 EXPECT_EQ(HexEncode(nistSPKIHash, base::SHA1_LENGTH),
625 HexEncode(verify_result.public_key_hashes[0].data, SHA1_LENGTH)); 625 HexEncode(verify_result.public_key_hashes[0].data, SHA1_LENGTH));
626 EXPECT_EQ("83244223D6CBF0A26FC7DE27CEBCA4BDA32612AD", 626 EXPECT_EQ("83244223D6CBF0A26FC7DE27CEBCA4BDA32612AD",
627 HexEncode(verify_result.public_key_hashes[1].data, SHA1_LENGTH)); 627 HexEncode(verify_result.public_key_hashes[1].data, SHA1_LENGTH));
628 628
629 TestRootCerts::GetInstance()->Clear(); 629 TestRootCerts::GetInstance()->Clear();
630 } 630 }
631 631
632 // A regression test for http://crbug.com/70293. 632 // A regression test for http://crbug.com/70293.
633 // The Key Usage extension in this RSA SSL server certificate does not have 633 // The Key Usage extension in this RSA SSL server certificate does not have
634 // the keyEncipherment bit. 634 // the keyEncipherment bit.
635 TEST(X509CertificateTest, InvalidKeyUsage) { 635 TEST(X509CertificateTest, InvalidKeyUsage) {
636 FilePath certs_dir = GetTestCertsDirectory(); 636 FilePath certs_dir = GetTestCertsDirectory();
637 637
638 scoped_refptr<X509Certificate> server_cert = 638 scoped_refptr<X509Certificate> server_cert =
639 ImportCertFromFile(certs_dir, "invalid_key_usage_cert.der"); 639 ImportCertFromFile(certs_dir, "invalid_key_usage_cert.der");
640 ASSERT_NE(static_cast<X509Certificate*>(NULL), server_cert); 640 ASSERT_NE(static_cast<X509Certificate*>(NULL), server_cert);
641 641
642 int flags = 0; 642 int flags = 0;
643 CertVerifyResult verify_result; 643 CertVerifyResult verify_result;
644 int error = server_cert->Verify("jira.aquameta.com", flags, &verify_result); 644 int error = server_cert->Verify("jira.aquameta.com", flags, &verify_result);
645 #if defined(USE_OPENSSL) 645 #if defined(USE_OPENSSL)
646 // This certificate has two errors: "invalid key usage" and "untrusted CA". 646 // This certificate has two errors: "invalid key usage" and "untrusted CA".
647 // However, OpenSSL returns only one (the latter), and we can't detect 647 // However, OpenSSL returns only one (the latter), and we can't detect
648 // the other errors. 648 // the other errors.
649 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error); 649 EXPECT_EQ(ERR_CERT_AUTHORITY_INVALID, error);
650 #else 650 #else
651 EXPECT_EQ(ERR_CERT_INVALID, error); 651 EXPECT_EQ(ERR_CERT_INVALID, error);
652 EXPECT_NE(0, verify_result.cert_status & CERT_STATUS_INVALID); 652 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_INVALID);
653 #endif 653 #endif
654 // TODO(wtc): fix http://crbug.com/75520 to get all the certificate errors 654 // TODO(wtc): fix http://crbug.com/75520 to get all the certificate errors
655 // from NSS. 655 // from NSS.
656 #if !defined(USE_NSS) 656 #if !defined(USE_NSS)
657 // The certificate is issued by an unknown CA. 657 // The certificate is issued by an unknown CA.
658 EXPECT_NE(0, verify_result.cert_status & CERT_STATUS_AUTHORITY_INVALID); 658 EXPECT_TRUE(verify_result.cert_status & CERT_STATUS_AUTHORITY_INVALID);
659 #endif 659 #endif
660 } 660 }
661 661
662 // Tests X509CertificateCache via X509Certificate::CreateFromHandle. We 662 // Tests X509CertificateCache via X509Certificate::CreateFromHandle. We
663 // call X509Certificate::CreateFromHandle several times and observe whether 663 // call X509Certificate::CreateFromHandle several times and observe whether
664 // it returns a cached or new OSCertHandle. 664 // it returns a cached or new OSCertHandle.
665 TEST(X509CertificateTest, Cache) { 665 TEST(X509CertificateTest, Cache) {
666 X509Certificate::OSCertHandle google_cert_handle; 666 X509Certificate::OSCertHandle google_cert_handle;
667 X509Certificate::OSCertHandle thawte_cert_handle; 667 X509Certificate::OSCertHandle thawte_cert_handle;
668 668
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 } 1373 }
1374 1374
1375 EXPECT_EQ(test_data.expected, X509Certificate::VerifyHostname( 1375 EXPECT_EQ(test_data.expected, X509Certificate::VerifyHostname(
1376 test_data.hostname, common_name, dns_names, ip_addressses)); 1376 test_data.hostname, common_name, dns_names, ip_addressses));
1377 } 1377 }
1378 1378
1379 INSTANTIATE_TEST_CASE_P(, X509CertificateNameVerifyTest, 1379 INSTANTIATE_TEST_CASE_P(, X509CertificateNameVerifyTest,
1380 testing::ValuesIn(kNameVerifyTestData)); 1380 testing::ValuesIn(kNameVerifyTestData));
1381 1381
1382 } // namespace net 1382 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698