]>
Commit | Line | Data |
---|---|---|
92e3827b AJ |
1 | /* |
2 | * Copyright (C) 1996-2016 The Squid Software Foundation and contributors | |
3 | * | |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
9 | #ifndef SQUID_SRC_SECURITY_CERTERROR_H | |
10 | #define SQUID_SRC_SECURITY_CERTERROR_H | |
11 | ||
12 | #include "security/forward.h" | |
13 | ||
14 | namespace Security | |
15 | { | |
16 | ||
17 | /// An X.509 certificate-related error. | |
18 | /// Pairs an error code with the certificate experiencing the error. | |
19 | class CertError | |
20 | { | |
21 | public: | |
22 | CertError(int anErr, const Security::CertPointer &aCert, int aDepth = -1) : | |
23 | code(anErr), cert(aCert), depth(aDepth) | |
24 | {} | |
25 | ||
26 | bool operator == (const CertError &ce) const { | |
27 | // We expect to be used in contexts where identical certificates have | |
28 | // identical pointers. | |
29 | return code == ce.code && depth == ce.depth && cert == ce.cert; | |
30 | } | |
31 | ||
32 | bool operator != (const CertError &ce) const { | |
33 | return !(*this == ce); | |
34 | } | |
35 | ||
36 | public: | |
37 | Security::ErrorCode code; ///< certificate error code | |
38 | Security::CertPointer cert; ///< certificate with the above error code | |
39 | ||
40 | /** | |
41 | * Absolute cert position in the final certificate chain that may include | |
42 | * intermediate certificates. Chain positions start with zero and increase | |
43 | * towards the root certificate. Negative if unknown. | |
44 | */ | |
45 | int depth; | |
46 | }; | |
47 | ||
48 | } // namespace Security | |
49 | ||
50 | #endif /* SQUID_SRC_SECURITY_CERTERROR_H */ | |
51 |