|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef __RECENTBADCERTS_H__ |
|
8 #define __RECENTBADCERTS_H__ |
|
9 |
|
10 #include "mozilla/Attributes.h" |
|
11 #include "mozilla/ReentrantMonitor.h" |
|
12 |
|
13 #include "nsIRecentBadCertsService.h" |
|
14 #include "nsTHashtable.h" |
|
15 #include "nsString.h" |
|
16 #include "cert.h" |
|
17 #include "secitem.h" |
|
18 |
|
19 class RecentBadCert |
|
20 { |
|
21 public: |
|
22 |
|
23 RecentBadCert() |
|
24 { |
|
25 mDERCert.len = 0; |
|
26 mDERCert.data = nullptr; |
|
27 isDomainMismatch = false; |
|
28 isNotValidAtThisTime = false; |
|
29 isUntrusted = false; |
|
30 } |
|
31 |
|
32 ~RecentBadCert() |
|
33 { |
|
34 Clear(); |
|
35 } |
|
36 |
|
37 void Clear() |
|
38 { |
|
39 mHostWithPort.Truncate(); |
|
40 if (mDERCert.len) |
|
41 nsMemory::Free(mDERCert.data); |
|
42 mDERCert.len = 0; |
|
43 mDERCert.data = nullptr; |
|
44 } |
|
45 |
|
46 nsString mHostWithPort; |
|
47 SECItem mDERCert; |
|
48 bool isDomainMismatch; |
|
49 bool isNotValidAtThisTime; |
|
50 bool isUntrusted; |
|
51 |
|
52 private: |
|
53 RecentBadCert(const RecentBadCert &other) MOZ_DELETE; |
|
54 RecentBadCert &operator=(const RecentBadCert &other) MOZ_DELETE; |
|
55 }; |
|
56 |
|
57 class nsRecentBadCerts MOZ_FINAL : public nsIRecentBadCerts |
|
58 { |
|
59 public: |
|
60 NS_DECL_THREADSAFE_ISUPPORTS |
|
61 NS_DECL_NSIRECENTBADCERTS |
|
62 |
|
63 nsRecentBadCerts(); |
|
64 ~nsRecentBadCerts(); |
|
65 |
|
66 protected: |
|
67 mozilla::ReentrantMonitor monitor; |
|
68 |
|
69 enum {const_recently_seen_list_size = 5}; |
|
70 RecentBadCert mCerts[const_recently_seen_list_size]; |
|
71 |
|
72 // will be in the range of 0 to list_size-1 |
|
73 uint32_t mNextStorePosition; |
|
74 }; |
|
75 |
|
76 #define NS_RECENTBADCERTS_CID { /* e7caf8c0-3570-47fe-aa1b-da47539b5d07 */ \ |
|
77 0xe7caf8c0, \ |
|
78 0x3570, \ |
|
79 0x47fe, \ |
|
80 {0xaa, 0x1b, 0xda, 0x47, 0x53, 0x9b, 0x5d, 0x07} \ |
|
81 } |
|
82 |
|
83 #endif |