Botan 3.11.0
Crypto and TLS for C&
certstor_macos.h
Go to the documentation of this file.
1/*
2* Certificate Store
3* (C) 1999-2019 Jack Lloyd
4* (C) 2019 René Meusel
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#ifndef BOTAN_CERT_STORE_SYSTEM_MACOS_H_
10#define BOTAN_CERT_STORE_SYSTEM_MACOS_H_
11
12#include <botan/certstor.h>
13#include <memory>
14
15// Use Certificate_Store_System instead
16BOTAN_FUTURE_INTERNAL_HEADER(certstor_macos.h)
17
18namespace Botan {
19
20class Certificate_Store_MacOS_Impl;
21
22/**
23* Certificate Store that is backed by the system trust store on macOS. This
24* opens a handle to the macOS keychain and serves certificate queries directly
25* from there.
26*/
28 public:
30
35
36 /**
37 * @return DNs for all certificates managed by the store
38 */
39 std::vector<X509_DN> all_subjects() const override;
40
41 /**
42 * Find a certificate by Subject DN and (optionally) key identifier
43 * @return the first certificate that matches
44 */
45 std::optional<X509_Certificate> find_cert(const X509_DN& subject_dn,
46 const std::vector<uint8_t>& key_id) const override;
47
48 /**
49 * Find all certificates with a given Subject DN.
50 * Subject DN and even the key identifier might not be unique.
51 */
52 std::vector<X509_Certificate> find_all_certs(const X509_DN& subject_dn,
53 const std::vector<uint8_t>& key_id) const override;
54
55 /**
56 * Find a certificate by searching for one with a matching SHA-1 hash of
57 * public key.
58 * @return a matching certificate or nullptr otherwise
59 */
60 std::optional<X509_Certificate> find_cert_by_pubkey_sha1(const std::vector<uint8_t>& key_hash) const override;
61
62 /**
63 * @throws Not_Implemented as this functionality is not available in the
64 * macOS certificate interface
65 */
66 std::optional<X509_Certificate> find_cert_by_raw_subject_dn_sha256(
67 const std::vector<uint8_t>& subject_hash) const override;
68
69 std::optional<X509_Certificate> find_cert_by_issuer_dn_and_serial_number(
70 const X509_DN& issuer_dn, std::span<const uint8_t> serial_number) const override;
71
72 /**
73 * Fetching CRLs is not supported by the keychain on macOS. This will
74 * always return an empty list.
75 */
76 std::optional<X509_CRL> find_crl_for(const X509_Certificate& subject) const override;
77
78 private:
79 std::shared_ptr<Certificate_Store_MacOS_Impl> m_impl;
80};
81
82} // namespace Botan
83
84#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition api.h:98
Certificate_Store_MacOS & operator=(Certificate_Store_MacOS &&)=default
Certificate_Store_MacOS(Certificate_Store_MacOS &&)=default
Certificate_Store_MacOS(const Certificate_Store_MacOS &)=default
Certificate_Store_MacOS & operator=(const Certificate_Store_MacOS &)=default
virtual std::optional< X509_CRL > find_crl_for(const X509_Certificate &subject) const
Definition certstor.cpp:34
virtual std::vector< X509_DN > all_subjects() const =0
virtual std::optional< X509_Certificate > find_cert_by_raw_subject_dn_sha256(const std::vector< uint8_t > &subject_hash) const =0
virtual std::optional< X509_Certificate > find_cert_by_issuer_dn_and_serial_number(const X509_DN &issuer_dn, std::span< const uint8_t > serial_number) const =0
virtual std::optional< X509_Certificate > find_cert_by_pubkey_sha1(const std::vector< uint8_t > &key_hash) const =0
virtual std::vector< X509_Certificate > find_all_certs(const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const =0
virtual std::optional< X509_Certificate > find_cert(const X509_DN &subject_dn, const std::vector< uint8_t > &key_id) const
Definition certstor.cpp:22