/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#pragma once

#include <fizz/protocol/CertificateVerifier.h>

namespace quic::test {

class TestCertificateVerifier : public fizz::CertificateVerifier {
 public:
  ~TestCertificateVerifier() override = default;

  std::shared_ptr<const folly::AsyncTransportCertificate> verify(
      const std::vector<std::shared_ptr<const fizz::PeerCert>>& certs)
      const override {
    return certs.front();
  }

  [[nodiscard]] std::vector<fizz::Extension> getCertificateRequestExtensions()
      const override {
    return std::vector<fizz::Extension>();
  }
};

inline std::unique_ptr<fizz::CertificateVerifier>
createTestCertificateVerifier() {
  return std::make_unique<TestCertificateVerifier>();
}

} // namespace quic::test

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#pragma once

#include <fizz/protocol/CertificateVerifier.h>

namespace quic::test {

class TestCertificateVerifier : public fizz::CertificateVerifier {
 public:
  ~TestCertificateVerifier() override = default;

  void verify(const std::vector<std::shared_ptr<const fizz::PeerCert>>&)
      const override {
    return;
  }

  [[nodiscard]] std::vector<fizz::Extension> getCertificateRequestExtensions()
      const override {
    return std::vector<fizz::Extension>();
  }
};

inline std::unique_ptr<fizz::CertificateVerifier>
createTestCertificateVerifier() {
  return std::make_unique<TestCertificateVerifier>();
}

} // namespace quic::test

--- 
+++ 
@@ -15,9 +15,10 @@
  public:
   ~TestCertificateVerifier() override = default;
 
-  void verify(const std::vector<std::shared_ptr<const fizz::PeerCert>>&)
+  std::shared_ptr<const folly::AsyncTransportCertificate> verify(
+      const std::vector<std::shared_ptr<const fizz::PeerCert>>& certs)
       const override {
-    return;
+    return certs.front();
   }
 
   [[nodiscard]] std::vector<fizz::Extension> getCertificateRequestExtensions()
Replace fizz server cert with leaf cert returned from verification

Summary: Added code to return the leaf cert after successfully verification of the server cert. The returned cert is then used for replacing the server cert.

Reviewed By: AjanthanAsogamoorthy

Differential Revision: D35898220

fbshipit-source-id: 8f542471a711d5aa62d0aad4c1d12b10c2209744
