Qt 4.8
Public Types | Public Functions | Properties | List of all members
QSslError Class Reference

The QSslError class provides an SSL error. More...

#include <qsslerror.h>

Public Types

enum  SslError {
  NoError, UnableToGetIssuerCertificate, UnableToDecryptCertificateSignature, UnableToDecodeIssuerPublicKey,
  CertificateSignatureFailed, CertificateNotYetValid, CertificateExpired, InvalidNotBeforeField,
  InvalidNotAfterField, SelfSignedCertificate, SelfSignedCertificateInChain, UnableToGetLocalIssuerCertificate,
  UnableToVerifyFirstCertificate, CertificateRevoked, InvalidCaCertificate, PathLengthExceeded,
  InvalidPurpose, CertificateUntrusted, CertificateRejected, SubjectIssuerMismatch,
  AuthorityIssuerSerialNumberMismatch, NoPeerCertificate, HostNameMismatch, NoSslSupport,
  CertificateBlacklisted, UnspecifiedError = -1
}
 Describes all recognized errors that can occur during an SSL handshake. More...
 

Public Functions

QSslCertificate certificate () const
 Returns the certificate associated with this error, or a null certificate if the error does not relate to any certificate. More...
 
SslError error () const
 Returns the type of the error. More...
 
QString errorString () const
 Returns a short localized human-readable description of the error. More...
 
bool operator!= (const QSslError &other) const
 Returns true if this error is not equal to other; otherwise returns false. More...
 
QSslErroroperator= (const QSslError &other)
 Assigns the contents of other to this error. More...
 
bool operator== (const QSslError &other) const
 Returns true if this error is equal to other; otherwise returns false. More...
 
 QSslError ()
 Constructs a QSslError object with no error and default certificate. More...
 
 QSslError (SslError error)
 Constructs a QSslError object. More...
 
 QSslError (SslError error, const QSslCertificate &certificate)
 Constructs a QSslError object. More...
 
 QSslError (const QSslError &other)
 Constructs an identical copy of other. More...
 
 ~QSslError ()
 Destroys the QSslError object. More...
 

Properties

QScopedPointer< QSslErrorPrivated
 

Detailed Description

The QSslError class provides an SSL error.

Since
4.3
Note
This class or function is reentrant.
Attention
Module: QtNetwork

QSslError provides a simple API for managing errors during QSslSocket's SSL handshake.

See also
QSslSocket, QSslCertificate, QSslCipher

Definition at line 58 of file qsslerror.h.

Enumerations

◆ SslError

Describes all recognized errors that can occur during an SSL handshake.

  • NoError
  • UnableToGetIssuerCertificate
  • UnableToDecryptCertificateSignature
  • UnableToDecodeIssuerPublicKey
  • CertificateSignatureFailed
  • CertificateNotYetValid
  • CertificateExpired
  • InvalidNotBeforeField
  • InvalidNotAfterField
  • SelfSignedCertificate
  • SelfSignedCertificateInChain
  • UnableToGetLocalIssuerCertificate
  • UnableToVerifyFirstCertificate
  • CertificateRevoked
  • InvalidCaCertificate
  • PathLengthExceeded
  • InvalidPurpose
  • CertificateUntrusted
  • CertificateRejected
  • SubjectIssuerMismatch
  • AuthorityIssuerSerialNumberMismatch
  • NoPeerCertificate
  • HostNameMismatch
  • UnspecifiedError
  • NoSslSupport
  • CertificateBlacklisted
See also
QSslError::errorString()
Enumerator
NoError 
UnableToGetIssuerCertificate 
UnableToDecryptCertificateSignature 
UnableToDecodeIssuerPublicKey 
CertificateSignatureFailed 
CertificateNotYetValid 
CertificateExpired 
InvalidNotBeforeField 
InvalidNotAfterField 
SelfSignedCertificate 
SelfSignedCertificateInChain 
UnableToGetLocalIssuerCertificate 
UnableToVerifyFirstCertificate 
CertificateRevoked 
InvalidCaCertificate 
PathLengthExceeded 
InvalidPurpose 
CertificateUntrusted 
CertificateRejected 
SubjectIssuerMismatch 
AuthorityIssuerSerialNumberMismatch 
NoPeerCertificate 
HostNameMismatch 
NoSslSupport 
CertificateBlacklisted 
UnspecifiedError 

Definition at line 61 of file qsslerror.h.

61  {
62  NoError,
81  SubjectIssuerMismatch, // hostname mismatch?
87  UnspecifiedError = -1
88  };

Constructors and Destructors

◆ QSslError() [1/4]

QSslError::QSslError ( )

Constructs a QSslError object with no error and default certificate.

Definition at line 122 of file qsslerror.cpp.

Referenced by operator<<().

123  : d(new QSslErrorPrivate)
124 {
127 }
QSslCertificate certificate
Definition: qsslerror.cpp:112
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109
QSslError::SslError error
Definition: qsslerror.cpp:111
The QSslCertificate class provides a convenient API for an X509 certificate.

◆ QSslError() [2/4]

QSslError::QSslError ( SslError  error)

Constructs a QSslError object.

The argument specifies the error that occurred.

Definition at line 134 of file qsslerror.cpp.

135  : d(new QSslErrorPrivate)
136 {
137  d->error = error;
139 }
QSslCertificate certificate
Definition: qsslerror.cpp:112
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109
QSslError::SslError error
Definition: qsslerror.cpp:111
The QSslCertificate class provides a convenient API for an X509 certificate.
SslError error() const
Returns the type of the error.
Definition: qsslerror.cpp:214

◆ QSslError() [3/4]

QSslError::QSslError ( SslError  error,
const QSslCertificate certificate 
)

Constructs a QSslError object.

The two arguments specify the error that occurred, and which certificate the error relates to.

See also
QSslCertificate

Definition at line 147 of file qsslerror.cpp.

148  : d(new QSslErrorPrivate)
149 {
150  d->error = error;
152 }
QSslCertificate certificate() const
Returns the certificate associated with this error, or a null certificate if the error does not relat...
Definition: qsslerror.cpp:317
QSslCertificate certificate
Definition: qsslerror.cpp:112
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109
QSslError::SslError error
Definition: qsslerror.cpp:111
SslError error() const
Returns the type of the error.
Definition: qsslerror.cpp:214

◆ QSslError() [4/4]

QSslError::QSslError ( const QSslError other)

Constructs an identical copy of other.

Definition at line 157 of file qsslerror.cpp.

158  : d(new QSslErrorPrivate)
159 {
160  *d.data() = *other.d.data();
161 }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109

◆ ~QSslError()

QSslError::~QSslError ( )

Destroys the QSslError object.

Definition at line 166 of file qsslerror.cpp.

167 {
168 }

Functions

◆ certificate()

QSslCertificate QSslError::certificate ( ) const

Returns the certificate associated with this error, or a null certificate if the error does not relate to any certificate.

See also
error(), errorString()

Definition at line 317 of file qsslerror.cpp.

Referenced by QSslError().

318 {
319  return d->certificate;
320 }
QSslCertificate certificate
Definition: qsslerror.cpp:112
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109

◆ error()

QSslError::SslError QSslError::error ( ) const

Returns the type of the error.

See also
errorString(), certificate()

Definition at line 214 of file qsslerror.cpp.

Referenced by QSslError().

215 {
216  return d->error;
217 }
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109
QSslError::SslError error
Definition: qsslerror.cpp:111

◆ errorString()

QString QSslError::errorString ( ) const

Returns a short localized human-readable description of the error.

See also
error(), certificate()

Definition at line 224 of file qsslerror.cpp.

Referenced by operator<<(), and QSslSocketBackendPrivate::startHandshake().

225 {
226  QString errStr;
227  switch (d->error) {
228  case NoError:
229  errStr = QSslSocket::tr("No error");
230  break;
232  errStr = QSslSocket::tr("The issuer certificate could not be found");
233  break;
235  errStr = QSslSocket::tr("The certificate signature could not be decrypted");
236  break;
238  errStr = QSslSocket::tr("The public key in the certificate could not be read");
239  break;
241  errStr = QSslSocket::tr("The signature of the certificate is invalid");
242  break;
244  errStr = QSslSocket::tr("The certificate is not yet valid");
245  break;
246  case CertificateExpired:
247  errStr = QSslSocket::tr("The certificate has expired");
248  break;
250  errStr = QSslSocket::tr("The certificate's notBefore field contains an invalid time");
251  break;
253  errStr = QSslSocket::tr("The certificate's notAfter field contains an invalid time");
254  break;
256  errStr = QSslSocket::tr("The certificate is self-signed, and untrusted");
257  break;
259  errStr = QSslSocket::tr("The root certificate of the certificate chain is self-signed, and untrusted");
260  break;
262  errStr = QSslSocket::tr("The issuer certificate of a locally looked up certificate could not be found");
263  break;
265  errStr = QSslSocket::tr("No certificates could be verified");
266  break;
268  errStr = QSslSocket::tr("One of the CA certificates is invalid");
269  break;
270  case PathLengthExceeded:
271  errStr = QSslSocket::tr("The basicConstraints path length parameter has been exceeded");
272  break;
273  case InvalidPurpose:
274  errStr = QSslSocket::tr("The supplied certificate is unsuitable for this purpose");
275  break;
277  errStr = QSslSocket::tr("The root CA certificate is not trusted for this purpose");
278  break;
279  case CertificateRejected:
280  errStr = QSslSocket::tr("The root CA certificate is marked to reject the specified purpose");
281  break;
282  case SubjectIssuerMismatch: // hostname mismatch
283  errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because its"
284  " subject name did not match the issuer name of the current certificate");
285  break;
287  errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because"
288  " its issuer name and serial number was present and did not match the"
289  " authority key identifier of the current certificate");
290  break;
291  case NoPeerCertificate:
292  errStr = QSslSocket::tr("The peer did not present any certificate");
293  break;
294  case HostNameMismatch:
295  errStr = QSslSocket::tr("The host name did not match any of the valid hosts"
296  " for this certificate");
297  break;
298  case NoSslSupport:
299  break;
301  errStr = QSslSocket::tr("The peer certificate is blacklisted");
302  break;
303  default:
304  errStr = QSslSocket::tr("Unknown error");
305  break;
306  }
307 
308  return errStr;
309 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109
QSslError::SslError error
Definition: qsslerror.cpp:111

◆ operator!=()

bool QSslError::operator!= ( const QSslError other) const
inline

Returns true if this error is not equal to other; otherwise returns false.

Since
4.4

Definition at line 101 of file qsslerror.h.

102  { return !(*this == other); }

◆ operator=()

QSslError & QSslError::operator= ( const QSslError other)

Assigns the contents of other to this error.

Since
4.4

Definition at line 178 of file qsslerror.cpp.

179 {
180  *d.data() = *other.d.data();
181  return *this;
182 }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109

◆ operator==()

bool QSslError::operator== ( const QSslError other) const

Returns true if this error is equal to other; otherwise returns false.

Since
4.4

Definition at line 192 of file qsslerror.cpp.

193 {
194  return d->error == other.d->error
195  && d->certificate == other.d->certificate;
196 }
QSslCertificate certificate
Definition: qsslerror.cpp:112
QScopedPointer< QSslErrorPrivate > d
Definition: qsslerror.h:109
QSslError::SslError error
Definition: qsslerror.cpp:111

Properties

◆ d

QScopedPointer<QSslErrorPrivate> QSslError::d
private

Definition at line 109 of file qsslerror.h.

Referenced by certificate(), error(), errorString(), operator=(), operator==(), and QSslError().


The documentation for this class was generated from the following files: