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/. */
6 #ifndef nsNSSCertificate_h
7 #define nsNSSCertificate_h
9 #include "ScopedNSSTypes.h"
11 #include "mozilla/DataMutex.h"
12 #include "mozilla/Maybe.h"
14 #include "nsIClassInfo.h"
15 #include "nsISerializable.h"
16 #include "nsIX509Cert.h"
17 #include "nsStringFwd.h"
19 class nsNSSCertificate final
: public nsIX509Cert
,
20 public nsISerializable
,
23 NS_DECL_THREADSAFE_ISUPPORTS
25 NS_DECL_NSISERIALIZABLE
29 explicit nsNSSCertificate(CERTCertificate
* cert
);
30 explicit nsNSSCertificate(nsTArray
<uint8_t>&& der
);
33 virtual ~nsNSSCertificate() = default;
34 nsresult
GetCertificateHash(nsAString
& aFingerprint
, SECOidTag aHashAlg
);
35 mozilla::UniqueCERTCertificate
GetOrInstantiateCert();
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
;
43 #define NS_X509CERT_CID \
44 { /* 660a3226-915c-4ffb-bb20-8985a632df05 */ \
45 0x660a3226, 0x915c, 0x4ffb, { \
46 0xbb, 0x20, 0x89, 0x85, 0xa6, 0x32, 0xdf, 0x05 \
50 #endif // nsNSSCertificate_h