Changeset View
Changeset View
Standalone View
Standalone View
src/core/ktcpsocket.cpp
Show First 20 Lines • Show All 189 Lines • ▼ Show 20 Line(s) | 189 | case QSslError::PathLengthExceeded: | |||
---|---|---|---|---|---|
190 | return KSslError::PathLengthExceeded; | 190 | return KSslError::PathLengthExceeded; | ||
191 | case QSslError::UnspecifiedError: | 191 | case QSslError::UnspecifiedError: | ||
192 | case QSslError::NoSslSupport: | 192 | case QSslError::NoSslSupport: | ||
193 | default: | 193 | default: | ||
194 | return KSslError::UnknownError; | 194 | return KSslError::UnknownError; | ||
195 | } | 195 | } | ||
196 | } | 196 | } | ||
197 | 197 | | |||
198 | static QString errorString(KSslError::Error e) | 198 | static QSslError::SslError errorFromKSslError(KSslError::Error e) | ||
199 | { | 199 | { | ||
200 | switch (e) { | 200 | switch (e) { | ||
201 | case KSslError::NoError: | 201 | case KSslError::NoError: | ||
202 | return i18nc("SSL error", "No error"); | 202 | return QSslError::NoError; | ||
203 | case KSslError::InvalidCertificateAuthorityCertificate: | 203 | case KSslError::InvalidCertificateAuthorityCertificate: | ||
204 | return i18nc("SSL error", "The certificate authority's certificate is invalid"); | 204 | return QSslError::InvalidCaCertificate; | ||
205 | case KSslError::InvalidCertificate: | ||||
206 | return QSslError::UnableToDecodeIssuerPublicKey; | ||||
207 | case KSslError::CertificateSignatureFailed: | ||||
208 | return QSslError::CertificateSignatureFailed; | ||||
209 | case KSslError::SelfSignedCertificate: | ||||
210 | return QSslError::SelfSignedCertificate; | ||||
205 | case KSslError::ExpiredCertificate: | 211 | case KSslError::ExpiredCertificate: | ||
212 | return QSslError::CertificateExpired; | ||||
213 | case KSslError::RevokedCertificate: | ||||
214 | return QSslError::CertificateRevoked; | ||||
215 | case KSslError::InvalidCertificatePurpose: | ||||
216 | return QSslError::InvalidPurpose; | ||||
217 | case KSslError::RejectedCertificate: | ||||
218 | return QSslError::CertificateRejected; | ||||
219 | case KSslError::UntrustedCertificate: | ||||
220 | return QSslError::CertificateUntrusted; | ||||
221 | case KSslError::NoPeerCertificate: | ||||
222 | return QSslError::NoPeerCertificate; | ||||
223 | case KSslError::HostNameMismatch: | ||||
224 | return QSslError::HostNameMismatch; | ||||
225 | case KSslError::PathLengthExceeded: | ||||
226 | return QSslError::PathLengthExceeded; | ||||
227 | case KSslError::UnknownError: | ||||
228 | default: | ||||
229 | return QSslError::UnspecifiedError; | ||||
230 | } | ||||
231 | } | ||||
232 | | ||||
233 | static QString errorString(QSslError::SslError e) | ||||
234 | { | ||||
235 | switch (e) { | ||||
236 | case QSslError::NoError: | ||||
237 | return i18nc("SSL error", "No error"); | ||||
238 | case QSslError::UnableToGetLocalIssuerCertificate: | ||||
239 | case QSslError::InvalidCaCertificate: | ||||
240 | return i18nc("SSL error", "The certificate authority's certificate is invalid"); | ||||
241 | case QSslError::InvalidNotBeforeField: | ||||
242 | case QSslError::InvalidNotAfterField: | ||||
243 | case QSslError::CertificateNotYetValid: | ||||
244 | case QSslError::CertificateExpired: | ||||
206 | return i18nc("SSL error", "The certificate has expired"); | 245 | return i18nc("SSL error", "The certificate has expired"); | ||
207 | case KSslError::InvalidCertificate: | 246 | case QSslError::UnableToDecodeIssuerPublicKey: | ||
247 | case QSslError::SubjectIssuerMismatch: | ||||
248 | case QSslError::AuthorityIssuerSerialNumberMismatch: | ||||
208 | return i18nc("SSL error", "The certificate is invalid"); | 249 | return i18nc("SSL error", "The certificate is invalid"); | ||
209 | case KSslError::SelfSignedCertificate: | 250 | case QSslError::SelfSignedCertificate: | ||
251 | case QSslError::SelfSignedCertificateInChain: | ||||
210 | return i18nc("SSL error", "The certificate is not signed by any trusted certificate authority"); | 252 | return i18nc("SSL error", "The certificate is not signed by any trusted certificate authority"); | ||
211 | case KSslError::RevokedCertificate: | 253 | case QSslError::CertificateRevoked: | ||
212 | return i18nc("SSL error", "The certificate has been revoked"); | 254 | return i18nc("SSL error", "The certificate has been revoked"); | ||
213 | case KSslError::InvalidCertificatePurpose: | 255 | case QSslError::InvalidPurpose: | ||
214 | return i18nc("SSL error", "The certificate is unsuitable for this purpose"); | 256 | return i18nc("SSL error", "The certificate is unsuitable for this purpose"); | ||
215 | case KSslError::UntrustedCertificate: | 257 | case QSslError::CertificateUntrusted: | ||
216 | return i18nc("SSL error", "The root certificate authority's certificate is not trusted for this purpose"); | 258 | return i18nc("SSL error", "The root certificate authority's certificate is not trusted for this purpose"); | ||
217 | case KSslError::RejectedCertificate: | 259 | case QSslError::CertificateRejected: | ||
218 | return i18nc("SSL error", "The certificate authority's certificate is marked to reject this certificate's purpose"); | 260 | return i18nc("SSL error", "The certificate authority's certificate is marked to reject this certificate's purpose"); | ||
219 | case KSslError::NoPeerCertificate: | 261 | case QSslError::NoPeerCertificate: | ||
220 | return i18nc("SSL error", "The peer did not present any certificate"); | 262 | return i18nc("SSL error", "The peer did not present any certificate"); | ||
221 | case KSslError::HostNameMismatch: | 263 | case QSslError::HostNameMismatch: | ||
222 | return i18nc("SSL error", "The certificate does not apply to the given host"); | 264 | return i18nc("SSL error", "The certificate does not apply to the given host"); | ||
223 | case KSslError::CertificateSignatureFailed: | 265 | case QSslError::UnableToVerifyFirstCertificate: | ||
266 | case QSslError::UnableToDecryptCertificateSignature: | ||||
267 | case QSslError::UnableToGetIssuerCertificate: | ||||
268 | case QSslError::CertificateSignatureFailed: | ||||
224 | return i18nc("SSL error", "The certificate cannot be verified for internal reasons"); | 269 | return i18nc("SSL error", "The certificate cannot be verified for internal reasons"); | ||
225 | case KSslError::PathLengthExceeded: | 270 | case QSslError::PathLengthExceeded: | ||
226 | return i18nc("SSL error", "The certificate chain is too long"); | 271 | return i18nc("SSL error", "The certificate chain is too long"); | ||
227 | case KSslError::UnknownError: | 272 | case QSslError::UnspecifiedError: | ||
228 | default: | 273 | case QSslError::NoSslSupport: | ||
274 | default: // ### this captures ~15 more enum values that we might want to give better descriptions | ||||
229 | return i18nc("SSL error", "Unknown error"); | 275 | return i18nc("SSL error", "Unknown error"); | ||
230 | } | 276 | } | ||
231 | } | 277 | } | ||
232 | 278 | | |||
233 | KSslError::Error error; | 279 | QSslError error; | ||
234 | QSslCertificate certificate; | | |||
235 | }; | 280 | }; | ||
236 | 281 | | |||
237 | KSslError::KSslError(Error errorCode, const QSslCertificate &certificate) | 282 | KSslError::KSslError(Error errorCode, const QSslCertificate &certificate) | ||
238 | : d(new KSslErrorPrivate()) | 283 | : d(new KSslErrorPrivate()) | ||
239 | { | 284 | { | ||
240 | d->error = errorCode; | 285 | d->error = QSslError(d->errorFromKSslError(errorCode), certificate); | ||
241 | d->certificate = certificate; | | |||
242 | } | 286 | } | ||
243 | 287 | | |||
244 | KSslError::KSslError(const QSslError &other) | 288 | KSslError::KSslError(const QSslError &other) | ||
245 | : d(new KSslErrorPrivate()) | 289 | : d(new KSslErrorPrivate()) | ||
246 | { | 290 | { | ||
247 | d->error = KSslErrorPrivate::errorFromQSslError(other.error()); | 291 | d->error = other; | ||
248 | d->certificate = other.certificate(); | | |||
249 | } | 292 | } | ||
250 | 293 | | |||
251 | KSslError::KSslError(const KSslError &other) | 294 | KSslError::KSslError(const KSslError &other) | ||
252 | : d(new KSslErrorPrivate()) | 295 | : d(new KSslErrorPrivate()) | ||
253 | { | 296 | { | ||
254 | *d = *other.d; | 297 | *d = *other.d; | ||
255 | } | 298 | } | ||
256 | 299 | | |||
257 | KSslError::~KSslError() | 300 | KSslError::~KSslError() | ||
258 | { | 301 | { | ||
259 | delete d; | 302 | delete d; | ||
260 | } | 303 | } | ||
261 | 304 | | |||
262 | KSslError &KSslError::operator=(const KSslError &other) | 305 | KSslError &KSslError::operator=(const KSslError &other) | ||
263 | { | 306 | { | ||
264 | *d = *other.d; | 307 | *d = *other.d; | ||
265 | return *this; | 308 | return *this; | ||
266 | } | 309 | } | ||
267 | 310 | | |||
268 | KSslError::Error KSslError::error() const | 311 | KSslError::Error KSslError::error() const | ||
269 | { | 312 | { | ||
270 | return d->error; | 313 | return KSslErrorPrivate::errorFromQSslError(d->error.error()); | ||
271 | } | 314 | } | ||
272 | 315 | | |||
273 | QString KSslError::errorString() const | 316 | QString KSslError::errorString() const | ||
274 | { | 317 | { | ||
275 | return KSslErrorPrivate::errorString(d->error); | 318 | return KSslErrorPrivate::errorString(d->error.error()); | ||
276 | } | 319 | } | ||
277 | 320 | | |||
278 | QSslCertificate KSslError::certificate() const | 321 | QSslCertificate KSslError::certificate() const | ||
279 | { | 322 | { | ||
280 | return d->certificate; | 323 | return d->error.certificate(); | ||
281 | } | 324 | } | ||
282 | 325 | | |||
283 | class KTcpSocketPrivate | 326 | class KTcpSocketPrivate | ||
284 | { | 327 | { | ||
285 | public: | 328 | public: | ||
286 | explicit KTcpSocketPrivate(KTcpSocket *qq) | 329 | explicit KTcpSocketPrivate(KTcpSocket *qq) | ||
287 | : q(qq), | 330 | : q(qq), | ||
288 | certificatesLoaded(false), | 331 | certificatesLoaded(false), | ||
▲ Show 20 Lines • Show All 769 Lines • Show Last 20 Lines |