nsNSSCertificate.h (1702B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef nsNSSCertificate_h 7 #define nsNSSCertificate_h 8 9 #include "ScopedNSSTypes.h" 10 #include "certt.h" 11 #include "mozilla/DataMutex.h" 12 #include "mozilla/Maybe.h" 13 #include "nsCOMPtr.h" 14 #include "nsIClassInfo.h" 15 #include "nsISerializable.h" 16 #include "nsIX509Cert.h" 17 #include "nsStringFwd.h" 18 19 class nsNSSCertificate final : public nsIX509Cert, 20 public nsISerializable, 21 public nsIClassInfo { 22 public: 23 NS_DECL_THREADSAFE_ISUPPORTS 24 NS_DECL_NSIX509CERT 25 NS_DECL_NSISERIALIZABLE 26 NS_DECL_NSICLASSINFO 27 28 nsNSSCertificate(); 29 explicit nsNSSCertificate(CERTCertificate* cert); 30 explicit nsNSSCertificate(nsTArray<uint8_t>&& der); 31 32 private: 33 ~nsNSSCertificate() = default; 34 nsresult GetCertificateHash(nsAString& aFingerprint, SECOidTag aHashAlg); 35 mozilla::UniqueCERTCertificate GetOrInstantiateCert(); 36 37 nsTArray<uint8_t> mDER; 38 // There may be multiple threads running when mCert is actually instantiated, 39 // so it must be protected by a mutex. 40 mozilla::DataMutex<mozilla::Maybe<mozilla::UniqueCERTCertificate>> mCert; 41 }; 42 43 #define NS_X509CERT_CID \ 44 {/* 660a3226-915c-4ffb-bb20-8985a632df05 */ \ 45 0x660a3226, \ 46 0x915c, \ 47 0x4ffb, \ 48 {0xbb, 0x20, 0x89, 0x85, 0xa6, 0x32, 0xdf, 0x05}} 49 50 #endif // nsNSSCertificate_h