src/net/quic/quic_network_transaction_unittest.cc
// A single QUIC request fails because the certificate does not match the origin
// hostname, regardless of whether it matches the alternative service hostname.
A single QUIC request fails because the certificate does not match the origin
hostname, regardless of whether it matches the alternative service hostname.
A single QUIC request fails because the certificate does not match the origin hostname regardless of whether it matches the alternative service hostname .
TEST_P(QuicNetworkTransactionWithDestinationTest, InvalidCertificate) {
  if (destination_type_ == DIFFERENT)
    return;
  GURL url("https://mail.example.com/");
  origin1_ = url.host();
  origin2_ = "mail.example.org";
  SetQuicAlternativeService(origin1_);
  scoped_refptr<X509Certificate> cert(
      ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"));
  ASSERT_FALSE(cert->VerifyNameMatch(origin1_));
  ASSERT_TRUE(cert->VerifyNameMatch(origin2_));
  ProofVerifyDetailsChromium verify_details;
  verify_details.cert_verify_result.verified_cert = cert;
  verify_details.cert_verify_result.is_issued_by_known_root = true;
  crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details);
  MockQuicData mock_quic_data(version_);
  mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING);
  mock_quic_data.AddRead(ASYNC, 0);
  mock_quic_data.AddSocketDataToFactory(&socket_factory_);
  AddRefusedSocketData();
  HttpRequestInfo request;
  request.url = url;
  request.traffic_annotation =
      net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS);
  HttpNetworkTransaction trans(DEFAULT_PRIORITY, session_.get());
  TestCompletionCallback callback;
  int rv = trans.Start(&request, callback.callback(), net_log_.bound());
  EXPECT_THAT(callback.GetResult(rv), IsError(ERR_CONNECTION_REFUSED));
  EXPECT_TRUE(AllDataConsumed());
}
TEST_P ( QuicNetworkTransactionWithDestinationTest , InvalidCertificate ) { if ( destination_type_ == DIFFERENT ) return ; GURL url ( " " ) ; origin1_ = url . host ( ) ; origin2_ = " " ; SetQuicAlternativeService ( origin1_ ) ; scoped_refptr < X509Certificate > cert ( ImportCertFromFile ( GetTestCertsDirectory ( ) , " " ) ) ; ASSERT_FALSE ( cert -> VerifyNameMatch ( origin1_ ) ) ; ASSERT_TRUE ( cert -> VerifyNameMatch ( origin2_ ) ) ; ProofVerifyDetailsChromium verify_details ; verify_details . cert_verify_result . verified_cert = cert ; verify_details . cert_verify_result . is_issued_by_known_root = true ; crypto_client_stream_factory_ . AddProofVerifyDetails ( & verify_details ) ; MockQuicData mock_quic_data ( version_ ) ; mock_quic_data . AddRead ( ASYNC , ERR_IO_PENDING ) ; mock_quic_data . AddRead ( ASYNC , 0 ) ; mock_quic_data . AddSocketDataToFactory ( & socket_factory_ ) ; AddRefusedSocketData ( ) ; HttpRequestInfo request ; request . url = url ; request . traffic_annotation = net :: MutableNetworkTrafficAnnotationTag ( TRAFFIC_ANNOTATION_FOR_TESTS ) ; HttpNetworkTransaction trans ( DEFAULT_PRIORITY , session_ . get ( ) ) ; TestCompletionCallback callback ; int rv = trans . Start ( & request , callback . callback ( ) , net_log_ . bound ( ) ) ; EXPECT_THAT ( callback . GetResult ( rv ) , IsError ( ERR_CONNECTION_REFUSED ) ) ; EXPECT_TRUE ( AllDataConsumed ( ) ) ; }
A single QUIC request fails because the certificate does not match the origin
hostname, regardless of whether it matches the alternative service hostname.
A single QUIC request fails because the certificate does not match the origin hostname regardless of whether it matches the alternative service hostname .
// Not used for requests, but this provides a test case where the certificate // is valid for the hostname of the alternative service.