blob: 0f1e4ab3d61e96d695cc406c5e19c1a9ac7e084c [file] [log] [blame]
Matt Mueller4bda9ee2024-10-08 17:28:021// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/net/server_certificate_database_test_util.h"
6
7#include "base/containers/span.h"
8#include "base/containers/to_vector.h"
9#include "base/strings/string_number_conversions.h"
10#include "crypto/sha2.h"
11
12namespace net {
13
14ServerCertificateDatabase::CertInformation MakeCertInfo(
15 std::string_view der_cert,
16 chrome_browser_server_certificate_database::CertificateTrust::
17 CertificateTrustType trust_type) {
18 ServerCertificateDatabase::CertInformation cert_info;
19 cert_info.sha256hash_hex =
20 base::HexEncode(crypto::SHA256HashString(der_cert));
21 cert_info.cert_metadata.mutable_trust()->set_trust_type(trust_type);
22 cert_info.der_cert = base::ToVector(base::as_byte_span(der_cert));
23 return cert_info;
24}
25
26} // namespace net