Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef NET_CERT_INTERNAL_TRUST_STORE_MAC_H_ | |
| 6 #define NET_CERT_INTERNAL_TRUST_STORE_MAC_H_ | |
| 7 | |
| 8 #include <CoreFoundation/CoreFoundation.h> | |
| 9 | |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "base/mac/scoped_cftyperef.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "net/base/net_export.h" | |
| 14 #include "net/cert/internal/trust_store.h" | |
| 15 | |
| 16 namespace net { | |
| 17 | |
| 18 // TrustStoreMac is an implementation of TrustStore which uses macOS keychain | |
| 19 // to find trust anchors for path building. | |
| 20 class NET_EXPORT TrustStoreMac : public TrustStore { | |
| 21 public: | |
| 22 // Creates a TrustStoreMac which will find anchors that are trusted for | |
| 23 // |policy_oid|. For list of possible policy values, see: | |
| 24 // https://developer.apple.com/reference/security/1667150-certificate_key_and_ trust_servic/1670151-standard_policies_for_specific_c?language=objc | |
| 25 explicit TrustStoreMac(const void* policy_oid); | |
|
Ryan Sleevi
2017/02/14 19:26:17
Given that Line 56 stores this as a CFStringRef, i
mattm
2017/02/16 22:06:09
It should be a CFStringRef, but in older versions
| |
| 26 ~TrustStoreMac() override; | |
| 27 | |
| 28 // TrustStore implementation: | |
| 29 void FindTrustAnchorsForCert(const scoped_refptr<ParsedCertificate>& cert, | |
| 30 TrustAnchors* matches) const override; | |
| 31 | |
| 32 private: | |
| 33 FRIEND_TEST_ALL_PREFIXES(TrustStoreMacTest, MultiRootNotTrusted); | |
| 34 FRIEND_TEST_ALL_PREFIXES(TrustStoreMacTest, SystemCerts); | |
| 35 | |
| 36 // Finds certificates in the OS keychains whose Subject matches |name_data|. | |
| 37 // The result is an array of SecCertificateRef. | |
| 38 static base::ScopedCFTypeRef<CFArrayRef> | |
| 39 FindMatchingCertificatesForMacNormalizedSubject(CFDataRef name_data); | |
| 40 | |
| 41 // Filters an array of SecCertificateRef by trust for |policy_oid|, returning | |
| 42 // the results as TrustAnchors in |out_anchors|. | |
| 43 static void FilterTrustedCertificates(CFArrayRef matching_items, | |
| 44 const CFStringRef policy_oid, | |
| 45 TrustAnchors* out_anchors); | |
|
Ryan Sleevi
2017/02/14 19:26:17
This doesn't seem to be used in the unittest - mov
mattm
2017/02/16 22:06:09
Done.
| |
| 46 | |
| 47 // Gets the Issuer name of |cert|, as normalized by the OS. | |
|
Ryan Sleevi
2017/02/14 19:26:17
Perhaps we should expand on this documentation.
/
mattm
2017/02/16 22:06:09
Done.
| |
| 48 static base::ScopedCFTypeRef<CFDataRef> GetMacNormalizedIssuer( | |
| 49 const scoped_refptr<ParsedCertificate>& cert); | |
| 50 | |
| 51 // Finds trust anchors with the Subject |name_data|, which should be | |
| 52 // normalized as by the OS. | |
| 53 void FindTrustAnchorsByMacNormalizedSubject(CFDataRef name_data, | |
| 54 TrustAnchors* matches) const; | |
| 55 | |
| 56 const CFStringRef policy_oid_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(TrustStoreMac); | |
| 59 }; | |
| 60 | |
| 61 } // namespace net | |
| 62 | |
| 63 #endif // NET_CERT_INTERNAL_TRUST_STORE_MAC_H_ | |
| OLD | NEW |