Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslerror.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | class QSslErrorPrivate | - | ||||||
7 | { | - | ||||||
8 | public: | - | ||||||
9 | QSslError::SslError error; | - | ||||||
10 | QSslCertificate certificate; | - | ||||||
11 | }; | - | ||||||
12 | QSslError::QSslError() | - | ||||||
13 | : d(new QSslErrorPrivate) | - | ||||||
14 | { | - | ||||||
15 | d->error = QSslError::NoError; | - | ||||||
16 | d->certificate = QSslCertificate(); | - | ||||||
17 | } executed 739 times by 9 tests: end of block Executed by:
| 739 | ||||||
18 | - | |||||||
19 | - | |||||||
20 | - | |||||||
21 | - | |||||||
22 | - | |||||||
23 | - | |||||||
24 | QSslError::QSslError(SslError error) | - | ||||||
25 | : d(new QSslErrorPrivate) | - | ||||||
26 | { | - | ||||||
27 | d->error = error; | - | ||||||
28 | d->certificate = QSslCertificate(); | - | ||||||
29 | } executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||
30 | - | |||||||
31 | - | |||||||
32 | - | |||||||
33 | - | |||||||
34 | - | |||||||
35 | - | |||||||
36 | - | |||||||
37 | QSslError::QSslError(SslError error, const QSslCertificate &certificate) | - | ||||||
38 | : d(new QSslErrorPrivate) | - | ||||||
39 | { | - | ||||||
40 | d->error = error; | - | ||||||
41 | d->certificate = certificate; | - | ||||||
42 | } executed 810 times by 8 tests: end of block Executed by:
| 810 | ||||||
43 | - | |||||||
44 | - | |||||||
45 | - | |||||||
46 | - | |||||||
47 | QSslError::QSslError(const QSslError &other) | - | ||||||
48 | : d(new QSslErrorPrivate) | - | ||||||
49 | { | - | ||||||
50 | *d.data() = *other.d.data(); | - | ||||||
51 | } executed 638 times by 9 tests: end of block Executed by:
| 638 | ||||||
52 | - | |||||||
53 | - | |||||||
54 | - | |||||||
55 | - | |||||||
56 | QSslError::~QSslError() | - | ||||||
57 | { | - | ||||||
58 | } | - | ||||||
59 | - | |||||||
60 | - | |||||||
61 | - | |||||||
62 | - | |||||||
63 | - | |||||||
64 | - | |||||||
65 | QSslError &QSslError::operator=(const QSslError &other) | - | ||||||
66 | { | - | ||||||
67 | *d.data() = *other.d.data(); | - | ||||||
68 | return never executed: *this;return *this; never executed: return *this; | 0 | ||||||
69 | } | - | ||||||
70 | bool QSslError::operator==(const QSslError &other) const | - | ||||||
71 | { | - | ||||||
72 | return executed 73 times by 3 tests: d->error == other.d->errorreturn d->error == other.d->error && d->certificate == other.d->certificate; Executed by:
executed 73 times by 3 tests: return d->error == other.d->error && d->certificate == other.d->certificate; Executed by:
| 1-73 | ||||||
73 | && d->certificate == other.d->certificate
executed 73 times by 3 tests: return d->error == other.d->error && d->certificate == other.d->certificate; Executed by:
| 31-73 | ||||||
74 | } | - | ||||||
75 | QSslError::SslError QSslError::error() const | - | ||||||
76 | { | - | ||||||
77 | return executed 64 times by 3 tests: d->error;return d->error; Executed by:
executed 64 times by 3 tests: return d->error; Executed by:
| 64 | ||||||
78 | } | - | ||||||
79 | - | |||||||
80 | - | |||||||
81 | - | |||||||
82 | - | |||||||
83 | - | |||||||
84 | - | |||||||
85 | QString QSslError::errorString() const | - | ||||||
86 | { | - | ||||||
87 | QString errStr; | - | ||||||
88 | switch (d->error) { | - | ||||||
89 | case never executed: NoError:case NoError: never executed: case NoError: | 0 | ||||||
90 | errStr = QSslSocket::tr("No error"); | - | ||||||
91 | break; never executed: break; | 0 | ||||||
92 | case never executed: UnableToGetIssuerCertificate:case UnableToGetIssuerCertificate: never executed: case UnableToGetIssuerCertificate: | 0 | ||||||
93 | errStr = QSslSocket::tr("The issuer certificate could not be found"); | - | ||||||
94 | break; never executed: break; | 0 | ||||||
95 | case never executed: UnableToDecryptCertificateSignature:case UnableToDecryptCertificateSignature: never executed: case UnableToDecryptCertificateSignature: | 0 | ||||||
96 | errStr = QSslSocket::tr("The certificate signature could not be decrypted"); | - | ||||||
97 | break; never executed: break; | 0 | ||||||
98 | case never executed: UnableToDecodeIssuerPublicKey:case UnableToDecodeIssuerPublicKey: never executed: case UnableToDecodeIssuerPublicKey: | 0 | ||||||
99 | errStr = QSslSocket::tr("The public key in the certificate could not be read"); | - | ||||||
100 | break; never executed: break; | 0 | ||||||
101 | case never executed: CertificateSignatureFailed:case CertificateSignatureFailed: never executed: case CertificateSignatureFailed: | 0 | ||||||
102 | errStr = QSslSocket::tr("The signature of the certificate is invalid"); | - | ||||||
103 | break; never executed: break; | 0 | ||||||
104 | case never executed: CertificateNotYetValid:case CertificateNotYetValid: never executed: case CertificateNotYetValid: | 0 | ||||||
105 | errStr = QSslSocket::tr("The certificate is not yet valid"); | - | ||||||
106 | break; never executed: break; | 0 | ||||||
107 | case executed 2 times by 1 test: CertificateExpired:case CertificateExpired: Executed by:
executed 2 times by 1 test: case CertificateExpired: Executed by:
| 2 | ||||||
108 | errStr = QSslSocket::tr("The certificate has expired"); | - | ||||||
109 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||
110 | case never executed: InvalidNotBeforeField:case InvalidNotBeforeField: never executed: case InvalidNotBeforeField: | 0 | ||||||
111 | errStr = QSslSocket::tr("The certificate's notBefore field contains an invalid time"); | - | ||||||
112 | break; never executed: break; | 0 | ||||||
113 | case never executed: InvalidNotAfterField:case InvalidNotAfterField: never executed: case InvalidNotAfterField: | 0 | ||||||
114 | errStr = QSslSocket::tr("The certificate's notAfter field contains an invalid time"); | - | ||||||
115 | break; never executed: break; | 0 | ||||||
116 | case executed 60 times by 5 tests: SelfSignedCertificate:case SelfSignedCertificate: Executed by:
executed 60 times by 5 tests: case SelfSignedCertificate: Executed by:
| 60 | ||||||
117 | errStr = QSslSocket::tr("The certificate is self-signed, and untrusted"); | - | ||||||
118 | break; executed 60 times by 5 tests: break; Executed by:
| 60 | ||||||
119 | case never executed: SelfSignedCertificateInChain:case SelfSignedCertificateInChain: never executed: case SelfSignedCertificateInChain: | 0 | ||||||
120 | errStr = QSslSocket::tr("The root certificate of the certificate chain is self-signed, and untrusted"); | - | ||||||
121 | break; never executed: break; | 0 | ||||||
122 | case executed 13 times by 3 tests: UnableToGetLocalIssuerCertificate:case UnableToGetLocalIssuerCertificate: Executed by:
executed 13 times by 3 tests: case UnableToGetLocalIssuerCertificate: Executed by:
| 13 | ||||||
123 | errStr = QSslSocket::tr("The issuer certificate of a locally looked up certificate could not be found"); | - | ||||||
124 | break; executed 13 times by 3 tests: break; Executed by:
| 13 | ||||||
125 | case never executed: UnableToVerifyFirstCertificate:case UnableToVerifyFirstCertificate: never executed: case UnableToVerifyFirstCertificate: | 0 | ||||||
126 | errStr = QSslSocket::tr("No certificates could be verified"); | - | ||||||
127 | break; never executed: break; | 0 | ||||||
128 | case executed 1 time by 1 test: InvalidCaCertificate:case InvalidCaCertificate: Executed by:
executed 1 time by 1 test: case InvalidCaCertificate: Executed by:
| 1 | ||||||
129 | errStr = QSslSocket::tr("One of the CA certificates is invalid"); | - | ||||||
130 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||
131 | case never executed: PathLengthExceeded:case PathLengthExceeded: never executed: case PathLengthExceeded: | 0 | ||||||
132 | errStr = QSslSocket::tr("The basicConstraints path length parameter has been exceeded"); | - | ||||||
133 | break; never executed: break; | 0 | ||||||
134 | case executed 1 time by 1 test: InvalidPurpose:case InvalidPurpose: Executed by:
executed 1 time by 1 test: case InvalidPurpose: Executed by:
| 1 | ||||||
135 | errStr = QSslSocket::tr("The supplied certificate is unsuitable for this purpose"); | - | ||||||
136 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||
137 | case never executed: CertificateUntrusted:case CertificateUntrusted: never executed: case CertificateUntrusted: | 0 | ||||||
138 | errStr = QSslSocket::tr("The root CA certificate is not trusted for this purpose"); | - | ||||||
139 | break; never executed: break; | 0 | ||||||
140 | case never executed: CertificateRejected:case CertificateRejected: never executed: case CertificateRejected: | 0 | ||||||
141 | errStr = QSslSocket::tr("The root CA certificate is marked to reject the specified purpose"); | - | ||||||
142 | break; never executed: break; | 0 | ||||||
143 | case never executed: SubjectIssuerMismatch:case SubjectIssuerMismatch: never executed: case SubjectIssuerMismatch: | 0 | ||||||
144 | errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because its" | - | ||||||
145 | " subject name did not match the issuer name of the current certificate"); | - | ||||||
146 | break; never executed: break; | 0 | ||||||
147 | case never executed: AuthorityIssuerSerialNumberMismatch:case AuthorityIssuerSerialNumberMismatch: never executed: case AuthorityIssuerSerialNumberMismatch: | 0 | ||||||
148 | errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because" | - | ||||||
149 | " its issuer name and serial number was present and did not match the" | - | ||||||
150 | " authority key identifier of the current certificate"); | - | ||||||
151 | break; never executed: break; | 0 | ||||||
152 | case executed 1 time by 1 test: NoPeerCertificate:case NoPeerCertificate: Executed by:
executed 1 time by 1 test: case NoPeerCertificate: Executed by:
| 1 | ||||||
153 | errStr = QSslSocket::tr("The peer did not present any certificate"); | - | ||||||
154 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||
155 | case executed 11 times by 2 tests: HostNameMismatch:case HostNameMismatch: Executed by:
executed 11 times by 2 tests: case HostNameMismatch: Executed by:
| 11 | ||||||
156 | errStr = QSslSocket::tr("The host name did not match any of the valid hosts" | - | ||||||
157 | " for this certificate"); | - | ||||||
158 | break; executed 11 times by 2 tests: break; Executed by:
| 11 | ||||||
159 | case never executed: NoSslSupport:case NoSslSupport: never executed: case NoSslSupport: | 0 | ||||||
160 | break; never executed: break; | 0 | ||||||
161 | case executed 1 time by 1 test: CertificateBlacklisted:case CertificateBlacklisted: Executed by:
executed 1 time by 1 test: case CertificateBlacklisted: Executed by:
| 1 | ||||||
162 | errStr = QSslSocket::tr("The peer certificate is blacklisted"); | - | ||||||
163 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||
164 | default executed 2 times by 1 test: :default: Executed by:
executed 2 times by 1 test: default: Executed by:
| 2 | ||||||
165 | errStr = QSslSocket::tr("Unknown error"); | - | ||||||
166 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||
167 | } | - | ||||||
168 | - | |||||||
169 | return executed 92 times by 7 tests: errStr;return errStr; Executed by:
executed 92 times by 7 tests: return errStr; Executed by:
| 92 | ||||||
170 | } | - | ||||||
171 | - | |||||||
172 | - | |||||||
173 | - | |||||||
174 | - | |||||||
175 | - | |||||||
176 | - | |||||||
177 | - | |||||||
178 | QSslCertificate QSslError::certificate() const | - | ||||||
179 | { | - | ||||||
180 | return executed 2 times by 1 test: d->certificate;return d->certificate; Executed by:
executed 2 times by 1 test: return d->certificate; Executed by:
| 2 | ||||||
181 | } | - | ||||||
182 | - | |||||||
183 | - | |||||||
184 | - | |||||||
185 | - | |||||||
186 | - | |||||||
187 | - | |||||||
188 | uint qHash(const QSslError &key, uint seed) noexcept | - | ||||||
189 | { | - | ||||||
190 | - | |||||||
191 | seed ^= qHash(key.error()) + 0x9e3779b9 + (seed << 6) + (seed >> 2); | - | ||||||
192 | seed ^= qHash(key.certificate()) + 0x9e3779b9 + (seed << 6) + (seed >> 2); | - | ||||||
193 | return executed 2 times by 1 test: seed;return seed; Executed by:
executed 2 times by 1 test: return seed; Executed by:
| 2 | ||||||
194 | } | - | ||||||
195 | - | |||||||
196 | - | |||||||
197 | - | |||||||
198 | QDebug operator<<(QDebug debug, const QSslError &error) | - | ||||||
199 | { | - | ||||||
200 | debug << error.errorString(); | - | ||||||
201 | return never executed: debug;return debug; never executed: return debug; | 0 | ||||||
202 | } | - | ||||||
203 | QDebug operator<<(QDebug debug, const QSslError::SslError &error) | - | ||||||
204 | { | - | ||||||
205 | debug << QSslError(error).errorString(); | - | ||||||
206 | return never executed: debug;return debug; never executed: return debug; | 0 | ||||||
207 | } | - | ||||||
208 | - | |||||||
209 | - | |||||||
210 | - | |||||||
Switch to Source code | Preprocessed file |