| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "net/cert/internal/path_builder.h" | 5 #include "net/cert/internal/path_builder.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "net/cert/internal/cert_issuer_source_static.h" | 10 #include "net/cert/internal/cert_issuer_source_static.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 // (This test is very similar to TestEndEntityHasSameNameAndSpkiAsTrustAnchor | 153 // (This test is very similar to TestEndEntityHasSameNameAndSpkiAsTrustAnchor |
| 154 // but with different data; also in this test the target cert itself is in the | 154 // but with different data; also in this test the target cert itself is in the |
| 155 // trust store). | 155 // trust store). |
| 156 TEST_F(PathBuilderMultiRootTest, TargetHasNameAndSpkiOfTrustAnchor) { | 156 TEST_F(PathBuilderMultiRootTest, TargetHasNameAndSpkiOfTrustAnchor) { |
| 157 TrustStoreInMemory trust_store; | 157 TrustStoreInMemory trust_store; |
| 158 AddTrustedCertificate(a_by_b_, &trust_store); | 158 AddTrustedCertificate(a_by_b_, &trust_store); |
| 159 AddTrustedCertificate(b_by_f_, &trust_store); | 159 AddTrustedCertificate(b_by_f_, &trust_store); |
| 160 | 160 |
| 161 CertPathBuilder::Result result; | 161 CertPathBuilder::Result result; |
| 162 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, | 162 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, |
| 163 &result); | 163 KeyPurpose::ANY_EKU, &result); |
| 164 | 164 |
| 165 path_builder.Run(); | 165 path_builder.Run(); |
| 166 | 166 |
| 167 ASSERT_TRUE(result.HasValidPath()); | 167 ASSERT_TRUE(result.HasValidPath()); |
| 168 const auto& path = result.GetBestValidPath()->path; | 168 const auto& path = result.GetBestValidPath()->path; |
| 169 ASSERT_EQ(1U, path.certs.size()); | 169 ASSERT_EQ(1U, path.certs.size()); |
| 170 EXPECT_EQ(a_by_b_, path.certs[0]); | 170 EXPECT_EQ(a_by_b_, path.certs[0]); |
| 171 EXPECT_EQ(b_by_f_, path.trust_anchor->cert()); | 171 EXPECT_EQ(b_by_f_, path.trust_anchor->cert()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 // If the target cert is has the same name and key as a trust anchor, however | 174 // If the target cert is has the same name and key as a trust anchor, however |
| 175 // is NOT itself signed by a trust anchor, it fails. Although the provided SPKI | 175 // is NOT itself signed by a trust anchor, it fails. Although the provided SPKI |
| 176 // is trusted, the certificate contents cannot be verified. | 176 // is trusted, the certificate contents cannot be verified. |
| 177 TEST_F(PathBuilderMultiRootTest, TargetWithSameNameAsTrustAnchorFails) { | 177 TEST_F(PathBuilderMultiRootTest, TargetWithSameNameAsTrustAnchorFails) { |
| 178 TrustStoreInMemory trust_store; | 178 TrustStoreInMemory trust_store; |
| 179 AddTrustedCertificate(a_by_b_, &trust_store); | 179 AddTrustedCertificate(a_by_b_, &trust_store); |
| 180 | 180 |
| 181 CertPathBuilder::Result result; | 181 CertPathBuilder::Result result; |
| 182 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, | 182 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, |
| 183 &result); | 183 KeyPurpose::ANY_EKU, &result); |
| 184 | 184 |
| 185 path_builder.Run(); | 185 path_builder.Run(); |
| 186 | 186 |
| 187 EXPECT_FALSE(result.HasValidPath()); | 187 EXPECT_FALSE(result.HasValidPath()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Test a failed path building when the trust anchor is provided as a | 190 // Test a failed path building when the trust anchor is provided as a |
| 191 // supplemental certificate. Conceptually the following paths can be built: | 191 // supplemental certificate. Conceptually the following paths can be built: |
| 192 // | 192 // |
| 193 // B(C) <- C(D) <- [Trust anchor D] | 193 // B(C) <- C(D) <- [Trust anchor D] |
| 194 // B(C) <- C(D) <- D(D) <- [Trust anchor D] | 194 // B(C) <- C(D) <- D(D) <- [Trust anchor D] |
| 195 // | 195 // |
| 196 // The second one is extraneous given the shorter one, however path building | 196 // The second one is extraneous given the shorter one, however path building |
| 197 // will enumerate it if the shorter one failed validation. | 197 // will enumerate it if the shorter one failed validation. |
| 198 TEST_F(PathBuilderMultiRootTest, SelfSignedTrustAnchorSupplementalCert) { | 198 TEST_F(PathBuilderMultiRootTest, SelfSignedTrustAnchorSupplementalCert) { |
| 199 TrustStoreInMemory trust_store; | 199 TrustStoreInMemory trust_store; |
| 200 AddTrustedCertificate(d_by_d_, &trust_store); | 200 AddTrustedCertificate(d_by_d_, &trust_store); |
| 201 | 201 |
| 202 // The (extraneous) trust anchor D(D) is supplied as a certificate, as is the | 202 // The (extraneous) trust anchor D(D) is supplied as a certificate, as is the |
| 203 // intermediate needed for path building C(D). | 203 // intermediate needed for path building C(D). |
| 204 CertIssuerSourceStatic sync_certs; | 204 CertIssuerSourceStatic sync_certs; |
| 205 sync_certs.AddCert(d_by_d_); | 205 sync_certs.AddCert(d_by_d_); |
| 206 sync_certs.AddCert(c_by_d_); | 206 sync_certs.AddCert(c_by_d_); |
| 207 | 207 |
| 208 // C(D) is not valid at this time, so path building will fail. | 208 // C(D) is not valid at this time, so path building will fail. |
| 209 der::GeneralizedTime expired_time = {2016, 1, 1, 0, 0, 0}; | 209 der::GeneralizedTime expired_time = {2016, 1, 1, 0, 0, 0}; |
| 210 | 210 |
| 211 CertPathBuilder::Result result; | 211 CertPathBuilder::Result result; |
| 212 CertPathBuilder path_builder(b_by_c_, &trust_store, &signature_policy_, | 212 CertPathBuilder path_builder(b_by_c_, &trust_store, &signature_policy_, |
| 213 expired_time, &result); | 213 expired_time, KeyPurpose::ANY_EKU, &result); |
| 214 path_builder.AddCertIssuerSource(&sync_certs); | 214 path_builder.AddCertIssuerSource(&sync_certs); |
| 215 | 215 |
| 216 path_builder.Run(); | 216 path_builder.Run(); |
| 217 | 217 |
| 218 EXPECT_FALSE(result.HasValidPath()); | 218 EXPECT_FALSE(result.HasValidPath()); |
| 219 ASSERT_EQ(2U, result.paths.size()); | 219 ASSERT_EQ(2U, result.paths.size()); |
| 220 | 220 |
| 221 EXPECT_FALSE(result.paths[0]->IsValid()); | 221 EXPECT_FALSE(result.paths[0]->IsValid()); |
| 222 const auto& path0 = result.paths[0]->path; | 222 const auto& path0 = result.paths[0]->path; |
| 223 ASSERT_EQ(2U, path0.certs.size()); | 223 ASSERT_EQ(2U, path0.certs.size()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 236 // If the target cert is a self-signed cert whose key is a trust anchor, it | 236 // If the target cert is a self-signed cert whose key is a trust anchor, it |
| 237 // should verify. | 237 // should verify. |
| 238 TEST_F(PathBuilderMultiRootTest, TargetIsSelfSignedTrustAnchor) { | 238 TEST_F(PathBuilderMultiRootTest, TargetIsSelfSignedTrustAnchor) { |
| 239 TrustStoreInMemory trust_store; | 239 TrustStoreInMemory trust_store; |
| 240 AddTrustedCertificate(e_by_e_, &trust_store); | 240 AddTrustedCertificate(e_by_e_, &trust_store); |
| 241 // This is not necessary for the test, just an extra... | 241 // This is not necessary for the test, just an extra... |
| 242 AddTrustedCertificate(f_by_e_, &trust_store); | 242 AddTrustedCertificate(f_by_e_, &trust_store); |
| 243 | 243 |
| 244 CertPathBuilder::Result result; | 244 CertPathBuilder::Result result; |
| 245 CertPathBuilder path_builder(e_by_e_, &trust_store, &signature_policy_, time_, | 245 CertPathBuilder path_builder(e_by_e_, &trust_store, &signature_policy_, time_, |
| 246 &result); | 246 KeyPurpose::ANY_EKU, &result); |
| 247 | 247 |
| 248 path_builder.Run(); | 248 path_builder.Run(); |
| 249 | 249 |
| 250 ASSERT_TRUE(result.HasValidPath()); | 250 ASSERT_TRUE(result.HasValidPath()); |
| 251 const auto& path = result.GetBestValidPath()->path; | 251 const auto& path = result.GetBestValidPath()->path; |
| 252 ASSERT_EQ(1U, path.certs.size()); | 252 ASSERT_EQ(1U, path.certs.size()); |
| 253 EXPECT_EQ(e_by_e_, path.certs[0]); | 253 EXPECT_EQ(e_by_e_, path.certs[0]); |
| 254 EXPECT_EQ(e_by_e_, path.trust_anchor->cert()); | 254 EXPECT_EQ(e_by_e_, path.trust_anchor->cert()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 // If the target cert is directly issued by a trust anchor, it should verify | 257 // If the target cert is directly issued by a trust anchor, it should verify |
| 258 // without any intermediate certs being provided. | 258 // without any intermediate certs being provided. |
| 259 TEST_F(PathBuilderMultiRootTest, TargetDirectlySignedByTrustAnchor) { | 259 TEST_F(PathBuilderMultiRootTest, TargetDirectlySignedByTrustAnchor) { |
| 260 TrustStoreInMemory trust_store; | 260 TrustStoreInMemory trust_store; |
| 261 AddTrustedCertificate(b_by_f_, &trust_store); | 261 AddTrustedCertificate(b_by_f_, &trust_store); |
| 262 | 262 |
| 263 CertPathBuilder::Result result; | 263 CertPathBuilder::Result result; |
| 264 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, | 264 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, |
| 265 &result); | 265 KeyPurpose::ANY_EKU, &result); |
| 266 | 266 |
| 267 path_builder.Run(); | 267 path_builder.Run(); |
| 268 | 268 |
| 269 ASSERT_TRUE(result.HasValidPath()); | 269 ASSERT_TRUE(result.HasValidPath()); |
| 270 const auto& path = result.GetBestValidPath()->path; | 270 const auto& path = result.GetBestValidPath()->path; |
| 271 ASSERT_EQ(1U, path.certs.size()); | 271 ASSERT_EQ(1U, path.certs.size()); |
| 272 EXPECT_EQ(a_by_b_, path.certs[0]); | 272 EXPECT_EQ(a_by_b_, path.certs[0]); |
| 273 EXPECT_EQ(b_by_f_, path.trust_anchor->cert()); | 273 EXPECT_EQ(b_by_f_, path.trust_anchor->cert()); |
| 274 } | 274 } |
| 275 | 275 |
| 276 // Test that async cert queries are not made if the path can be successfully | 276 // Test that async cert queries are not made if the path can be successfully |
| 277 // built with synchronously available certs. | 277 // built with synchronously available certs. |
| 278 TEST_F(PathBuilderMultiRootTest, TriesSyncFirst) { | 278 TEST_F(PathBuilderMultiRootTest, TriesSyncFirst) { |
| 279 TrustStoreInMemory trust_store; | 279 TrustStoreInMemory trust_store; |
| 280 AddTrustedCertificate(e_by_e_, &trust_store); | 280 AddTrustedCertificate(e_by_e_, &trust_store); |
| 281 | 281 |
| 282 CertIssuerSourceStatic sync_certs; | 282 CertIssuerSourceStatic sync_certs; |
| 283 sync_certs.AddCert(b_by_f_); | 283 sync_certs.AddCert(b_by_f_); |
| 284 sync_certs.AddCert(f_by_e_); | 284 sync_certs.AddCert(f_by_e_); |
| 285 | 285 |
| 286 AsyncCertIssuerSourceStatic async_certs; | 286 AsyncCertIssuerSourceStatic async_certs; |
| 287 async_certs.AddCert(b_by_c_); | 287 async_certs.AddCert(b_by_c_); |
| 288 async_certs.AddCert(c_by_e_); | 288 async_certs.AddCert(c_by_e_); |
| 289 | 289 |
| 290 CertPathBuilder::Result result; | 290 CertPathBuilder::Result result; |
| 291 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, | 291 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, |
| 292 &result); | 292 KeyPurpose::ANY_EKU, &result); |
| 293 path_builder.AddCertIssuerSource(&async_certs); | 293 path_builder.AddCertIssuerSource(&async_certs); |
| 294 path_builder.AddCertIssuerSource(&sync_certs); | 294 path_builder.AddCertIssuerSource(&sync_certs); |
| 295 | 295 |
| 296 path_builder.Run(); | 296 path_builder.Run(); |
| 297 | 297 |
| 298 EXPECT_TRUE(result.HasValidPath()); | 298 EXPECT_TRUE(result.HasValidPath()); |
| 299 EXPECT_EQ(0, async_certs.num_async_gets()); | 299 EXPECT_EQ(0, async_certs.num_async_gets()); |
| 300 } | 300 } |
| 301 | 301 |
| 302 // If async queries are needed, all async sources will be queried | 302 // If async queries are needed, all async sources will be queried |
| 303 // simultaneously. | 303 // simultaneously. |
| 304 TEST_F(PathBuilderMultiRootTest, TestAsyncSimultaneous) { | 304 TEST_F(PathBuilderMultiRootTest, TestAsyncSimultaneous) { |
| 305 TrustStoreInMemory trust_store; | 305 TrustStoreInMemory trust_store; |
| 306 AddTrustedCertificate(e_by_e_, &trust_store); | 306 AddTrustedCertificate(e_by_e_, &trust_store); |
| 307 | 307 |
| 308 CertIssuerSourceStatic sync_certs; | 308 CertIssuerSourceStatic sync_certs; |
| 309 sync_certs.AddCert(b_by_c_); | 309 sync_certs.AddCert(b_by_c_); |
| 310 sync_certs.AddCert(b_by_f_); | 310 sync_certs.AddCert(b_by_f_); |
| 311 | 311 |
| 312 AsyncCertIssuerSourceStatic async_certs1; | 312 AsyncCertIssuerSourceStatic async_certs1; |
| 313 async_certs1.AddCert(c_by_e_); | 313 async_certs1.AddCert(c_by_e_); |
| 314 | 314 |
| 315 AsyncCertIssuerSourceStatic async_certs2; | 315 AsyncCertIssuerSourceStatic async_certs2; |
| 316 async_certs2.AddCert(f_by_e_); | 316 async_certs2.AddCert(f_by_e_); |
| 317 | 317 |
| 318 CertPathBuilder::Result result; | 318 CertPathBuilder::Result result; |
| 319 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, | 319 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, |
| 320 &result); | 320 KeyPurpose::ANY_EKU, &result); |
| 321 path_builder.AddCertIssuerSource(&async_certs1); | 321 path_builder.AddCertIssuerSource(&async_certs1); |
| 322 path_builder.AddCertIssuerSource(&async_certs2); | 322 path_builder.AddCertIssuerSource(&async_certs2); |
| 323 path_builder.AddCertIssuerSource(&sync_certs); | 323 path_builder.AddCertIssuerSource(&sync_certs); |
| 324 | 324 |
| 325 path_builder.Run(); | 325 path_builder.Run(); |
| 326 | 326 |
| 327 EXPECT_TRUE(result.HasValidPath()); | 327 EXPECT_TRUE(result.HasValidPath()); |
| 328 EXPECT_EQ(1, async_certs1.num_async_gets()); | 328 EXPECT_EQ(1, async_certs1.num_async_gets()); |
| 329 EXPECT_EQ(1, async_certs2.num_async_gets()); | 329 EXPECT_EQ(1, async_certs2.num_async_gets()); |
| 330 } | 330 } |
| 331 | 331 |
| 332 // Test that PathBuilder does not generate longer paths than necessary if one of | 332 // Test that PathBuilder does not generate longer paths than necessary if one of |
| 333 // the supplied certs is itself a trust anchor. | 333 // the supplied certs is itself a trust anchor. |
| 334 TEST_F(PathBuilderMultiRootTest, TestLongChain) { | 334 TEST_F(PathBuilderMultiRootTest, TestLongChain) { |
| 335 // Both D(D) and C(D) are trusted roots. | 335 // Both D(D) and C(D) are trusted roots. |
| 336 TrustStoreInMemory trust_store; | 336 TrustStoreInMemory trust_store; |
| 337 AddTrustedCertificate(d_by_d_, &trust_store); | 337 AddTrustedCertificate(d_by_d_, &trust_store); |
| 338 AddTrustedCertificate(c_by_d_, &trust_store); | 338 AddTrustedCertificate(c_by_d_, &trust_store); |
| 339 | 339 |
| 340 // Certs B(C), and C(D) are all supplied. | 340 // Certs B(C), and C(D) are all supplied. |
| 341 CertIssuerSourceStatic sync_certs; | 341 CertIssuerSourceStatic sync_certs; |
| 342 sync_certs.AddCert(b_by_c_); | 342 sync_certs.AddCert(b_by_c_); |
| 343 sync_certs.AddCert(c_by_d_); | 343 sync_certs.AddCert(c_by_d_); |
| 344 | 344 |
| 345 CertPathBuilder::Result result; | 345 CertPathBuilder::Result result; |
| 346 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, | 346 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, |
| 347 &result); | 347 KeyPurpose::ANY_EKU, &result); |
| 348 path_builder.AddCertIssuerSource(&sync_certs); | 348 path_builder.AddCertIssuerSource(&sync_certs); |
| 349 | 349 |
| 350 path_builder.Run(); | 350 path_builder.Run(); |
| 351 | 351 |
| 352 ASSERT_TRUE(result.HasValidPath()); | 352 ASSERT_TRUE(result.HasValidPath()); |
| 353 | 353 |
| 354 // The result path should be A(B) <- B(C) <- C(D) | 354 // The result path should be A(B) <- B(C) <- C(D) |
| 355 // not the longer but also valid A(B) <- B(C) <- C(D) <- D(D) | 355 // not the longer but also valid A(B) <- B(C) <- C(D) <- D(D) |
| 356 EXPECT_EQ(2U, result.GetBestValidPath()->path.certs.size()); | 356 EXPECT_EQ(2U, result.GetBestValidPath()->path.certs.size()); |
| 357 } | 357 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 370 sync_certs.AddCert(f_by_e_); | 370 sync_certs.AddCert(f_by_e_); |
| 371 | 371 |
| 372 // Certs B(C), and C(D) are supplied asynchronously, so the path | 372 // Certs B(C), and C(D) are supplied asynchronously, so the path |
| 373 // A(B) <- B(C) <- C(D) <- D(D) should be tried second. | 373 // A(B) <- B(C) <- C(D) <- D(D) should be tried second. |
| 374 AsyncCertIssuerSourceStatic async_certs; | 374 AsyncCertIssuerSourceStatic async_certs; |
| 375 async_certs.AddCert(b_by_c_); | 375 async_certs.AddCert(b_by_c_); |
| 376 async_certs.AddCert(c_by_d_); | 376 async_certs.AddCert(c_by_d_); |
| 377 | 377 |
| 378 CertPathBuilder::Result result; | 378 CertPathBuilder::Result result; |
| 379 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, | 379 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, time_, |
| 380 &result); | 380 KeyPurpose::ANY_EKU, &result); |
| 381 path_builder.AddCertIssuerSource(&sync_certs); | 381 path_builder.AddCertIssuerSource(&sync_certs); |
| 382 path_builder.AddCertIssuerSource(&async_certs); | 382 path_builder.AddCertIssuerSource(&async_certs); |
| 383 | 383 |
| 384 path_builder.Run(); | 384 path_builder.Run(); |
| 385 | 385 |
| 386 ASSERT_TRUE(result.HasValidPath()); | 386 ASSERT_TRUE(result.HasValidPath()); |
| 387 | 387 |
| 388 // The result path should be A(B) <- B(C) <- C(D) <- D(D) | 388 // The result path should be A(B) <- B(C) <- C(D) <- D(D) |
| 389 const auto& path = result.GetBestValidPath()->path; | 389 const auto& path = result.GetBestValidPath()->path; |
| 390 ASSERT_EQ(3U, path.certs.size()); | 390 ASSERT_EQ(3U, path.certs.size()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 409 if (reverse_order) { | 409 if (reverse_order) { |
| 410 for (auto it = certs.rbegin(); it != certs.rend(); ++it) | 410 for (auto it = certs.rbegin(); it != certs.rend(); ++it) |
| 411 sync_certs.AddCert(*it); | 411 sync_certs.AddCert(*it); |
| 412 } else { | 412 } else { |
| 413 for (const auto& cert : certs) | 413 for (const auto& cert : certs) |
| 414 sync_certs.AddCert(cert); | 414 sync_certs.AddCert(cert); |
| 415 } | 415 } |
| 416 | 416 |
| 417 CertPathBuilder::Result result; | 417 CertPathBuilder::Result result; |
| 418 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, | 418 CertPathBuilder path_builder(a_by_b_, &trust_store, &signature_policy_, |
| 419 time_, &result); | 419 time_, KeyPurpose::ANY_EKU, &result); |
| 420 path_builder.AddCertIssuerSource(&sync_certs); | 420 path_builder.AddCertIssuerSource(&sync_certs); |
| 421 | 421 |
| 422 path_builder.Run(); | 422 path_builder.Run(); |
| 423 | 423 |
| 424 ASSERT_TRUE(result.HasValidPath()); | 424 ASSERT_TRUE(result.HasValidPath()); |
| 425 | 425 |
| 426 // The result path should be A(B) <- B(C) <- C(D) <- D(D) | 426 // The result path should be A(B) <- B(C) <- C(D) <- D(D) |
| 427 const auto& path = result.GetBestValidPath()->path; | 427 const auto& path = result.GetBestValidPath()->path; |
| 428 ASSERT_EQ(3U, path.certs.size()); | 428 ASSERT_EQ(3U, path.certs.size()); |
| 429 EXPECT_EQ(a_by_b_, path.certs[0]); | 429 EXPECT_EQ(a_by_b_, path.certs[0]); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 trust_store.AddTrustAnchor(oldroot_); | 498 trust_store.AddTrustAnchor(oldroot_); |
| 499 | 499 |
| 500 // Old intermediate cert is not provided, so the pathbuilder will need to go | 500 // Old intermediate cert is not provided, so the pathbuilder will need to go |
| 501 // through the rollover cert. | 501 // through the rollover cert. |
| 502 CertIssuerSourceStatic sync_certs; | 502 CertIssuerSourceStatic sync_certs; |
| 503 sync_certs.AddCert(newintermediate_); | 503 sync_certs.AddCert(newintermediate_); |
| 504 sync_certs.AddCert(newrootrollover_); | 504 sync_certs.AddCert(newrootrollover_); |
| 505 | 505 |
| 506 CertPathBuilder::Result result; | 506 CertPathBuilder::Result result; |
| 507 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 507 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 508 &result); | 508 KeyPurpose::ANY_EKU, &result); |
| 509 path_builder.AddCertIssuerSource(&sync_certs); | 509 path_builder.AddCertIssuerSource(&sync_certs); |
| 510 | 510 |
| 511 path_builder.Run(); | 511 path_builder.Run(); |
| 512 | 512 |
| 513 EXPECT_TRUE(result.HasValidPath()); | 513 EXPECT_TRUE(result.HasValidPath()); |
| 514 | 514 |
| 515 // Path builder will first attempt: target <- newintermediate <- oldroot | 515 // Path builder will first attempt: target <- newintermediate <- oldroot |
| 516 // but it will fail since newintermediate is signed by newroot. | 516 // but it will fail since newintermediate is signed by newroot. |
| 517 ASSERT_EQ(2U, result.paths.size()); | 517 ASSERT_EQ(2U, result.paths.size()); |
| 518 const auto& path0 = result.paths[0]->path; | 518 const auto& path0 = result.paths[0]->path; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 546 AddTrustedCertificate(newroot_, &trust_store); | 546 AddTrustedCertificate(newroot_, &trust_store); |
| 547 | 547 |
| 548 // Both old and new intermediates + rollover cert are provided. | 548 // Both old and new intermediates + rollover cert are provided. |
| 549 CertIssuerSourceStatic sync_certs; | 549 CertIssuerSourceStatic sync_certs; |
| 550 sync_certs.AddCert(oldintermediate_); | 550 sync_certs.AddCert(oldintermediate_); |
| 551 sync_certs.AddCert(newintermediate_); | 551 sync_certs.AddCert(newintermediate_); |
| 552 sync_certs.AddCert(newrootrollover_); | 552 sync_certs.AddCert(newrootrollover_); |
| 553 | 553 |
| 554 CertPathBuilder::Result result; | 554 CertPathBuilder::Result result; |
| 555 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 555 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 556 &result); | 556 KeyPurpose::ANY_EKU, &result); |
| 557 path_builder.AddCertIssuerSource(&sync_certs); | 557 path_builder.AddCertIssuerSource(&sync_certs); |
| 558 | 558 |
| 559 path_builder.Run(); | 559 path_builder.Run(); |
| 560 | 560 |
| 561 EXPECT_TRUE(result.HasValidPath()); | 561 EXPECT_TRUE(result.HasValidPath()); |
| 562 | 562 |
| 563 // Path builder willattempt one of: | 563 // Path builder willattempt one of: |
| 564 // target <- oldintermediate <- oldroot | 564 // target <- oldintermediate <- oldroot |
| 565 // target <- newintermediate <- newroot | 565 // target <- newintermediate <- newroot |
| 566 // either will succeed. | 566 // either will succeed. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 582 | 582 |
| 583 // If trust anchor query returned no results, and there are no issuer | 583 // If trust anchor query returned no results, and there are no issuer |
| 584 // sources, path building should fail at that point. | 584 // sources, path building should fail at that point. |
| 585 TEST_F(PathBuilderKeyRolloverTest, TestAnchorsNoMatchAndNoIssuerSources) { | 585 TEST_F(PathBuilderKeyRolloverTest, TestAnchorsNoMatchAndNoIssuerSources) { |
| 586 TrustStoreInMemory trust_store; | 586 TrustStoreInMemory trust_store; |
| 587 trust_store.AddTrustAnchor( | 587 trust_store.AddTrustAnchor( |
| 588 TrustAnchor::CreateFromCertificateNoConstraints(newroot_)); | 588 TrustAnchor::CreateFromCertificateNoConstraints(newroot_)); |
| 589 | 589 |
| 590 CertPathBuilder::Result result; | 590 CertPathBuilder::Result result; |
| 591 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 591 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 592 &result); | 592 KeyPurpose::ANY_EKU, &result); |
| 593 | 593 |
| 594 path_builder.Run(); | 594 path_builder.Run(); |
| 595 | 595 |
| 596 EXPECT_FALSE(result.HasValidPath()); | 596 EXPECT_FALSE(result.HasValidPath()); |
| 597 | 597 |
| 598 ASSERT_EQ(0U, result.paths.size()); | 598 ASSERT_EQ(0U, result.paths.size()); |
| 599 } | 599 } |
| 600 | 600 |
| 601 // Tests that multiple trust root matches on a single path will be considered. | 601 // Tests that multiple trust root matches on a single path will be considered. |
| 602 // Both roots have the same subject but different keys. Only one of them will | 602 // Both roots have the same subject but different keys. Only one of them will |
| (...skipping 11 matching lines...) Expand all Loading... |
| 614 TrustAnchor::CreateFromCertificateNoConstraints(newroot_)); | 614 TrustAnchor::CreateFromCertificateNoConstraints(newroot_)); |
| 615 trust_store2.AddTrustAnchor(oldroot_); | 615 trust_store2.AddTrustAnchor(oldroot_); |
| 616 | 616 |
| 617 // Only oldintermediate is supplied, so the path with newroot should fail, | 617 // Only oldintermediate is supplied, so the path with newroot should fail, |
| 618 // oldroot should succeed. | 618 // oldroot should succeed. |
| 619 CertIssuerSourceStatic sync_certs; | 619 CertIssuerSourceStatic sync_certs; |
| 620 sync_certs.AddCert(oldintermediate_); | 620 sync_certs.AddCert(oldintermediate_); |
| 621 | 621 |
| 622 CertPathBuilder::Result result; | 622 CertPathBuilder::Result result; |
| 623 CertPathBuilder path_builder(target_, &trust_store_collection, | 623 CertPathBuilder path_builder(target_, &trust_store_collection, |
| 624 &signature_policy_, time_, &result); | 624 &signature_policy_, time_, KeyPurpose::ANY_EKU, |
| 625 &result); |
| 625 path_builder.AddCertIssuerSource(&sync_certs); | 626 path_builder.AddCertIssuerSource(&sync_certs); |
| 626 | 627 |
| 627 path_builder.Run(); | 628 path_builder.Run(); |
| 628 | 629 |
| 629 EXPECT_TRUE(result.HasValidPath()); | 630 EXPECT_TRUE(result.HasValidPath()); |
| 630 ASSERT_EQ(2U, result.paths.size()); | 631 ASSERT_EQ(2U, result.paths.size()); |
| 631 | 632 |
| 632 { | 633 { |
| 633 // Path builder may first attempt: target <- oldintermediate <- newroot | 634 // Path builder may first attempt: target <- oldintermediate <- newroot |
| 634 // but it will fail since oldintermediate is signed by oldroot. | 635 // but it will fail since oldintermediate is signed by oldroot. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 664 sync_certs.AddCert(newintermediate_); | 665 sync_certs.AddCert(newintermediate_); |
| 665 sync_certs.AddCert(newroot_); | 666 sync_certs.AddCert(newroot_); |
| 666 | 667 |
| 667 // Rollover cert is only provided asynchronously. This will force the | 668 // Rollover cert is only provided asynchronously. This will force the |
| 668 // pathbuilder to first try building a longer than necessary path. | 669 // pathbuilder to first try building a longer than necessary path. |
| 669 AsyncCertIssuerSourceStatic async_certs; | 670 AsyncCertIssuerSourceStatic async_certs; |
| 670 async_certs.AddCert(newrootrollover_); | 671 async_certs.AddCert(newrootrollover_); |
| 671 | 672 |
| 672 CertPathBuilder::Result result; | 673 CertPathBuilder::Result result; |
| 673 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 674 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 674 &result); | 675 KeyPurpose::ANY_EKU, &result); |
| 675 path_builder.AddCertIssuerSource(&sync_certs); | 676 path_builder.AddCertIssuerSource(&sync_certs); |
| 676 path_builder.AddCertIssuerSource(&async_certs); | 677 path_builder.AddCertIssuerSource(&async_certs); |
| 677 | 678 |
| 678 path_builder.Run(); | 679 path_builder.Run(); |
| 679 | 680 |
| 680 EXPECT_TRUE(result.HasValidPath()); | 681 EXPECT_TRUE(result.HasValidPath()); |
| 681 ASSERT_EQ(3U, result.paths.size()); | 682 ASSERT_EQ(3U, result.paths.size()); |
| 682 | 683 |
| 683 // Path builder will first attempt: target <- newintermediate <- oldroot | 684 // Path builder will first attempt: target <- newintermediate <- oldroot |
| 684 // but it will fail since newintermediate is signed by newroot. | 685 // but it will fail since newintermediate is signed by newroot. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 // trust anchor matches the SPKI and subject of the targe certificate, but the | 722 // trust anchor matches the SPKI and subject of the targe certificate, but the |
| 722 // rest of the certificate cannot be verified). | 723 // rest of the certificate cannot be verified). |
| 723 TEST_F(PathBuilderKeyRolloverTest, TestEndEntityIsTrustRoot) { | 724 TEST_F(PathBuilderKeyRolloverTest, TestEndEntityIsTrustRoot) { |
| 724 // Trust newintermediate. | 725 // Trust newintermediate. |
| 725 TrustStoreInMemory trust_store; | 726 TrustStoreInMemory trust_store; |
| 726 AddTrustedCertificate(newintermediate_, &trust_store); | 727 AddTrustedCertificate(newintermediate_, &trust_store); |
| 727 | 728 |
| 728 CertPathBuilder::Result result; | 729 CertPathBuilder::Result result; |
| 729 // Newintermediate is also the target cert. | 730 // Newintermediate is also the target cert. |
| 730 CertPathBuilder path_builder(newintermediate_, &trust_store, | 731 CertPathBuilder path_builder(newintermediate_, &trust_store, |
| 731 &signature_policy_, time_, &result); | 732 &signature_policy_, time_, KeyPurpose::ANY_EKU, |
| 733 &result); |
| 732 | 734 |
| 733 path_builder.Run(); | 735 path_builder.Run(); |
| 734 | 736 |
| 735 EXPECT_FALSE(result.HasValidPath()); | 737 EXPECT_FALSE(result.HasValidPath()); |
| 736 } | 738 } |
| 737 | 739 |
| 738 // If target has same Name+SAN+SPKI as a necessary intermediate, test if a path | 740 // If target has same Name+SAN+SPKI as a necessary intermediate, test if a path |
| 739 // can still be built. | 741 // can still be built. |
| 740 // Since LoopChecker will prevent the intermediate from being included, this | 742 // Since LoopChecker will prevent the intermediate from being included, this |
| 741 // currently does NOT verify. This case shouldn't occur in the web PKI. | 743 // currently does NOT verify. This case shouldn't occur in the web PKI. |
| 742 TEST_F(PathBuilderKeyRolloverTest, | 744 TEST_F(PathBuilderKeyRolloverTest, |
| 743 TestEndEntityHasSameNameAndSpkiAsIntermediate) { | 745 TestEndEntityHasSameNameAndSpkiAsIntermediate) { |
| 744 // Trust oldroot. | 746 // Trust oldroot. |
| 745 TrustStoreInMemory trust_store; | 747 TrustStoreInMemory trust_store; |
| 746 trust_store.AddTrustAnchor(oldroot_); | 748 trust_store.AddTrustAnchor(oldroot_); |
| 747 | 749 |
| 748 // New root rollover is provided synchronously. | 750 // New root rollover is provided synchronously. |
| 749 CertIssuerSourceStatic sync_certs; | 751 CertIssuerSourceStatic sync_certs; |
| 750 sync_certs.AddCert(newrootrollover_); | 752 sync_certs.AddCert(newrootrollover_); |
| 751 | 753 |
| 752 CertPathBuilder::Result result; | 754 CertPathBuilder::Result result; |
| 753 // Newroot is the target cert. | 755 // Newroot is the target cert. |
| 754 CertPathBuilder path_builder(newroot_, &trust_store, &signature_policy_, | 756 CertPathBuilder path_builder(newroot_, &trust_store, &signature_policy_, |
| 755 time_, &result); | 757 time_, KeyPurpose::ANY_EKU, &result); |
| 756 path_builder.AddCertIssuerSource(&sync_certs); | 758 path_builder.AddCertIssuerSource(&sync_certs); |
| 757 | 759 |
| 758 path_builder.Run(); | 760 path_builder.Run(); |
| 759 | 761 |
| 760 // This could actually be OK, but CertPathBuilder does not build the | 762 // This could actually be OK, but CertPathBuilder does not build the |
| 761 // newroot <- newrootrollover <- oldroot path. | 763 // newroot <- newrootrollover <- oldroot path. |
| 762 EXPECT_FALSE(result.HasValidPath()); | 764 EXPECT_FALSE(result.HasValidPath()); |
| 763 } | 765 } |
| 764 | 766 |
| 765 // If target has same Name+SAN+SPKI as the trust root, test that a (trivial) | 767 // If target has same Name+SAN+SPKI as the trust root, test that a (trivial) |
| 766 // path can still be built. | 768 // path can still be built. |
| 767 TEST_F(PathBuilderKeyRolloverTest, | 769 TEST_F(PathBuilderKeyRolloverTest, |
| 768 TestEndEntityHasSameNameAndSpkiAsTrustAnchor) { | 770 TestEndEntityHasSameNameAndSpkiAsTrustAnchor) { |
| 769 // Trust newrootrollover. | 771 // Trust newrootrollover. |
| 770 TrustStoreInMemory trust_store; | 772 TrustStoreInMemory trust_store; |
| 771 AddTrustedCertificate(newrootrollover_, &trust_store); | 773 AddTrustedCertificate(newrootrollover_, &trust_store); |
| 772 | 774 |
| 773 CertPathBuilder::Result result; | 775 CertPathBuilder::Result result; |
| 774 // Newroot is the target cert. | 776 // Newroot is the target cert. |
| 775 CertPathBuilder path_builder(newroot_, &trust_store, &signature_policy_, | 777 CertPathBuilder path_builder(newroot_, &trust_store, &signature_policy_, |
| 776 time_, &result); | 778 time_, KeyPurpose::ANY_EKU, &result); |
| 777 | 779 |
| 778 path_builder.Run(); | 780 path_builder.Run(); |
| 779 | 781 |
| 780 ASSERT_TRUE(result.HasValidPath()); | 782 ASSERT_TRUE(result.HasValidPath()); |
| 781 | 783 |
| 782 const CertPathBuilder::ResultPath* best_result = result.GetBestValidPath(); | 784 const CertPathBuilder::ResultPath* best_result = result.GetBestValidPath(); |
| 783 | 785 |
| 784 // Newroot has same name+SPKI as newrootrollover, thus the path is valid and | 786 // Newroot has same name+SPKI as newrootrollover, thus the path is valid and |
| 785 // only contains newroot. | 787 // only contains newroot. |
| 786 EXPECT_TRUE(best_result->IsValid()); | 788 EXPECT_TRUE(best_result->IsValid()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 814 CertIssuerSourceStatic sync_certs2; | 816 CertIssuerSourceStatic sync_certs2; |
| 815 sync_certs2.AddCert(oldintermediate_dupe); | 817 sync_certs2.AddCert(oldintermediate_dupe); |
| 816 | 818 |
| 817 // The newintermediate is supplied asynchronously, so the path | 819 // The newintermediate is supplied asynchronously, so the path |
| 818 // target <- newintermediate <- newroot should be tried second. | 820 // target <- newintermediate <- newroot should be tried second. |
| 819 AsyncCertIssuerSourceStatic async_certs; | 821 AsyncCertIssuerSourceStatic async_certs; |
| 820 async_certs.AddCert(newintermediate_); | 822 async_certs.AddCert(newintermediate_); |
| 821 | 823 |
| 822 CertPathBuilder::Result result; | 824 CertPathBuilder::Result result; |
| 823 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 825 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 824 &result); | 826 KeyPurpose::ANY_EKU, &result); |
| 825 path_builder.AddCertIssuerSource(&sync_certs1); | 827 path_builder.AddCertIssuerSource(&sync_certs1); |
| 826 path_builder.AddCertIssuerSource(&sync_certs2); | 828 path_builder.AddCertIssuerSource(&sync_certs2); |
| 827 path_builder.AddCertIssuerSource(&async_certs); | 829 path_builder.AddCertIssuerSource(&async_certs); |
| 828 | 830 |
| 829 path_builder.Run(); | 831 path_builder.Run(); |
| 830 | 832 |
| 831 EXPECT_TRUE(result.HasValidPath()); | 833 EXPECT_TRUE(result.HasValidPath()); |
| 832 ASSERT_EQ(2U, result.paths.size()); | 834 ASSERT_EQ(2U, result.paths.size()); |
| 833 | 835 |
| 834 // Path builder will first attempt: target <- oldintermediate <- newroot | 836 // Path builder will first attempt: target <- oldintermediate <- newroot |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 TrustStoreInMemory trust_store; | 870 TrustStoreInMemory trust_store; |
| 869 AddTrustedCertificate(newroot_, &trust_store); | 871 AddTrustedCertificate(newroot_, &trust_store); |
| 870 | 872 |
| 871 // The oldintermediate and newroot are supplied synchronously by |sync_certs|. | 873 // The oldintermediate and newroot are supplied synchronously by |sync_certs|. |
| 872 CertIssuerSourceStatic sync_certs; | 874 CertIssuerSourceStatic sync_certs; |
| 873 sync_certs.AddCert(oldintermediate_); | 875 sync_certs.AddCert(oldintermediate_); |
| 874 sync_certs.AddCert(newroot_dupe); | 876 sync_certs.AddCert(newroot_dupe); |
| 875 | 877 |
| 876 CertPathBuilder::Result result; | 878 CertPathBuilder::Result result; |
| 877 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 879 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 878 &result); | 880 KeyPurpose::ANY_EKU, &result); |
| 879 path_builder.AddCertIssuerSource(&sync_certs); | 881 path_builder.AddCertIssuerSource(&sync_certs); |
| 880 | 882 |
| 881 path_builder.Run(); | 883 path_builder.Run(); |
| 882 | 884 |
| 883 EXPECT_FALSE(result.HasValidPath()); | 885 EXPECT_FALSE(result.HasValidPath()); |
| 884 ASSERT_EQ(2U, result.paths.size()); | 886 ASSERT_EQ(2U, result.paths.size()); |
| 885 // TODO(eroman): Is this right? | 887 // TODO(eroman): Is this right? |
| 886 | 888 |
| 887 // Path builder attempt: target <- oldintermediate <- newroot | 889 // Path builder attempt: target <- oldintermediate <- newroot |
| 888 // but it will fail since oldintermediate is signed by oldroot. | 890 // but it will fail since oldintermediate is signed by oldroot. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 // builder does not request issuers of certs that it shouldn't. | 945 // builder does not request issuers of certs that it shouldn't. |
| 944 TEST_F(PathBuilderKeyRolloverTest, TestMultipleAsyncIssuersFromSingleSource) { | 946 TEST_F(PathBuilderKeyRolloverTest, TestMultipleAsyncIssuersFromSingleSource) { |
| 945 StrictMock<MockCertIssuerSource> cert_issuer_source; | 947 StrictMock<MockCertIssuerSource> cert_issuer_source; |
| 946 | 948 |
| 947 // Only newroot is a trusted root. | 949 // Only newroot is a trusted root. |
| 948 TrustStoreInMemory trust_store; | 950 TrustStoreInMemory trust_store; |
| 949 AddTrustedCertificate(newroot_, &trust_store); | 951 AddTrustedCertificate(newroot_, &trust_store); |
| 950 | 952 |
| 951 CertPathBuilder::Result result; | 953 CertPathBuilder::Result result; |
| 952 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 954 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 953 &result); | 955 KeyPurpose::ANY_EKU, &result); |
| 954 path_builder.AddCertIssuerSource(&cert_issuer_source); | 956 path_builder.AddCertIssuerSource(&cert_issuer_source); |
| 955 | 957 |
| 956 // Create the mock CertIssuerSource::Request... | 958 // Create the mock CertIssuerSource::Request... |
| 957 std::unique_ptr<StrictMock<MockCertIssuerSourceRequest>> | 959 std::unique_ptr<StrictMock<MockCertIssuerSourceRequest>> |
| 958 target_issuers_req_owner(new StrictMock<MockCertIssuerSourceRequest>()); | 960 target_issuers_req_owner(new StrictMock<MockCertIssuerSourceRequest>()); |
| 959 // Keep a raw pointer to the Request... | 961 // Keep a raw pointer to the Request... |
| 960 StrictMock<MockCertIssuerSourceRequest>* target_issuers_req = | 962 StrictMock<MockCertIssuerSourceRequest>* target_issuers_req = |
| 961 target_issuers_req_owner.get(); | 963 target_issuers_req_owner.get(); |
| 962 // Setup helper class to pass ownership of the Request to the PathBuilder when | 964 // Setup helper class to pass ownership of the Request to the PathBuilder when |
| 963 // it calls AsyncGetIssuersOf. | 965 // it calls AsyncGetIssuersOf. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 // asynchronously provide the same certificate multiple times. | 1024 // asynchronously provide the same certificate multiple times. |
| 1023 TEST_F(PathBuilderKeyRolloverTest, TestDuplicateAsyncIntermediates) { | 1025 TEST_F(PathBuilderKeyRolloverTest, TestDuplicateAsyncIntermediates) { |
| 1024 StrictMock<MockCertIssuerSource> cert_issuer_source; | 1026 StrictMock<MockCertIssuerSource> cert_issuer_source; |
| 1025 | 1027 |
| 1026 // Only newroot is a trusted root. | 1028 // Only newroot is a trusted root. |
| 1027 TrustStoreInMemory trust_store; | 1029 TrustStoreInMemory trust_store; |
| 1028 AddTrustedCertificate(newroot_, &trust_store); | 1030 AddTrustedCertificate(newroot_, &trust_store); |
| 1029 | 1031 |
| 1030 CertPathBuilder::Result result; | 1032 CertPathBuilder::Result result; |
| 1031 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, | 1033 CertPathBuilder path_builder(target_, &trust_store, &signature_policy_, time_, |
| 1032 &result); | 1034 KeyPurpose::ANY_EKU, &result); |
| 1033 path_builder.AddCertIssuerSource(&cert_issuer_source); | 1035 path_builder.AddCertIssuerSource(&cert_issuer_source); |
| 1034 | 1036 |
| 1035 // Create the mock CertIssuerSource::Request... | 1037 // Create the mock CertIssuerSource::Request... |
| 1036 std::unique_ptr<StrictMock<MockCertIssuerSourceRequest>> | 1038 std::unique_ptr<StrictMock<MockCertIssuerSourceRequest>> |
| 1037 target_issuers_req_owner(new StrictMock<MockCertIssuerSourceRequest>()); | 1039 target_issuers_req_owner(new StrictMock<MockCertIssuerSourceRequest>()); |
| 1038 // Keep a raw pointer to the Request... | 1040 // Keep a raw pointer to the Request... |
| 1039 StrictMock<MockCertIssuerSourceRequest>* target_issuers_req = | 1041 StrictMock<MockCertIssuerSourceRequest>* target_issuers_req = |
| 1040 target_issuers_req_owner.get(); | 1042 target_issuers_req_owner.get(); |
| 1041 // Setup helper class to pass ownership of the Request to the PathBuilder when | 1043 // Setup helper class to pass ownership of the Request to the PathBuilder when |
| 1042 // it calls AsyncGetIssuersOf. | 1044 // it calls AsyncGetIssuersOf. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 const auto& path1 = result.paths[1]->path; | 1104 const auto& path1 = result.paths[1]->path; |
| 1103 ASSERT_EQ(2U, path1.certs.size()); | 1105 ASSERT_EQ(2U, path1.certs.size()); |
| 1104 EXPECT_EQ(target_, path1.certs[0]); | 1106 EXPECT_EQ(target_, path1.certs[0]); |
| 1105 EXPECT_EQ(newintermediate_, path1.certs[1]); | 1107 EXPECT_EQ(newintermediate_, path1.certs[1]); |
| 1106 EXPECT_EQ(newroot_, path1.trust_anchor->cert()); | 1108 EXPECT_EQ(newroot_, path1.trust_anchor->cert()); |
| 1107 } | 1109 } |
| 1108 | 1110 |
| 1109 } // namespace | 1111 } // namespace |
| 1110 | 1112 |
| 1111 } // namespace net | 1113 } // namespace net |
| OLD | NEW |