src/network/ssl/qsslerror.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    89 
    89 
    90     \sa QSslError::errorString()
    90     \sa QSslError::errorString()
    91 */
    91 */
    92 
    92 
    93 #include "qsslerror.h"
    93 #include "qsslerror.h"
       
    94 #include "qsslsocket.h"
    94 #ifndef QT_NO_DEBUG_STREAM
    95 #ifndef QT_NO_DEBUG_STREAM
    95 #include <QtCore/qdebug.h>
    96 #include <QtCore/qdebug.h>
    96 
    97 
    97 QT_BEGIN_NAMESPACE
    98 QT_BEGIN_NAMESPACE
    98 #endif
    99 #endif
   207 QString QSslError::errorString() const
   208 QString QSslError::errorString() const
   208 {
   209 {
   209     QString errStr;
   210     QString errStr;
   210     switch (d->error) {
   211     switch (d->error) {
   211     case NoError:
   212     case NoError:
   212         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "No error"));
   213         errStr = QSslSocket::tr("No error");
   213         break;
   214         break;
   214     case UnableToGetIssuerCertificate:
   215     case UnableToGetIssuerCertificate:
   215         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The issuer certificate could not be found"));
   216         errStr = QSslSocket::tr("The issuer certificate could not be found");
   216         break;
   217         break;
   217     case UnableToDecryptCertificateSignature:
   218     case UnableToDecryptCertificateSignature:
   218         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate signature could not be decrypted"));
   219         errStr = QSslSocket::tr("The certificate signature could not be decrypted");
   219         break;
   220         break;
   220     case UnableToDecodeIssuerPublicKey:
   221     case UnableToDecodeIssuerPublicKey:
   221         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The public key in the certificate could not be read"));
   222         errStr = QSslSocket::tr("The public key in the certificate could not be read");
   222         break;
   223         break;
   223     case CertificateSignatureFailed:
   224     case CertificateSignatureFailed:
   224         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The signature of the certificate is invalid"));
   225         errStr = QSslSocket::tr("The signature of the certificate is invalid");
   225         break;
   226         break;
   226     case CertificateNotYetValid:
   227     case CertificateNotYetValid:
   227         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is not yet valid"));
   228         errStr = QSslSocket::tr("The certificate is not yet valid");
   228         break;
   229         break;
   229     case CertificateExpired:
   230     case CertificateExpired:
   230         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate has expired"));
   231         errStr = QSslSocket::tr("The certificate has expired");
   231         break;
   232         break;
   232     case InvalidNotBeforeField:
   233     case InvalidNotBeforeField:
   233         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate's notBefore field contains an invalid time"));
   234         errStr = QSslSocket::tr("The certificate's notBefore field contains an invalid time");
   234         break;
   235         break;
   235     case InvalidNotAfterField:
   236     case InvalidNotAfterField:
   236         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate's notAfter field contains an invalid time"));
   237         errStr = QSslSocket::tr("The certificate's notAfter field contains an invalid time");
   237         break;
   238         break;
   238     case SelfSignedCertificate:
   239     case SelfSignedCertificate:
   239         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The certificate is self-signed, and untrusted"));
   240         errStr = QSslSocket::tr("The certificate is self-signed, and untrusted");
   240         break;
   241         break;
   241     case SelfSignedCertificateInChain:
   242     case SelfSignedCertificateInChain:
   242         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The root certificate of the certificate chain is self-signed, and untrusted"));
   243         errStr = QSslSocket::tr("The root certificate of the certificate chain is self-signed, and untrusted");
   243         break;
   244         break;
   244     case UnableToGetLocalIssuerCertificate:
   245     case UnableToGetLocalIssuerCertificate:
   245         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The issuer certificate of a locally looked up certificate could not be found"));
   246         errStr = QSslSocket::tr("The issuer certificate of a locally looked up certificate could not be found");
   246         break;
   247         break;
   247     case UnableToVerifyFirstCertificate:
   248     case UnableToVerifyFirstCertificate:
   248         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "No certificates could be verified"));
   249         errStr = QSslSocket::tr("No certificates could be verified");
   249         break;
   250         break;
   250     case InvalidCaCertificate:
   251     case InvalidCaCertificate:
   251         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "One of the CA certificates is invalid"));
   252         errStr = QSslSocket::tr("One of the CA certificates is invalid");
   252         break;
   253         break;
   253     case PathLengthExceeded:
   254     case PathLengthExceeded:
   254         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The basicConstraints pathlength parameter has been exceeded"));
   255         errStr = QSslSocket::tr("The basicConstraints path length parameter has been exceeded");
   255         break;
   256         break;
   256     case InvalidPurpose:
   257     case InvalidPurpose:
   257         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The supplied certificate is unsuited for this purpose"));
   258         errStr = QSslSocket::tr("The supplied certificate is unsuitable for this purpose");
   258         break;
   259         break;
   259     case CertificateUntrusted:
   260     case CertificateUntrusted:
   260         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The root CA certificate is not trusted for this purpose"));
   261         errStr = QSslSocket::tr("The root CA certificate is not trusted for this purpose");
   261         break;
   262         break;
   262     case CertificateRejected:
   263     case CertificateRejected:
   263         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The root CA certificate is marked to reject the specified purpose"));
   264         errStr = QSslSocket::tr("The root CA certificate is marked to reject the specified purpose");
   264         break;
   265         break;
   265     case SubjectIssuerMismatch: // hostname mismatch
   266     case SubjectIssuerMismatch: // hostname mismatch
   266         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError,
   267         errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because its"
   267                                                "The current candidate issuer certificate was rejected because its"
   268                                 " subject name did not match the issuer name of the current certificate");
   268                                                " subject name did not match the issuer name of the current certificate"));
       
   269         break;
   269         break;
   270     case AuthorityIssuerSerialNumberMismatch:
   270     case AuthorityIssuerSerialNumberMismatch:
   271         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The current candidate issuer certificate was rejected because"
   271         errStr = QSslSocket::tr("The current candidate issuer certificate was rejected because"
   272                                                " its issuer name and serial number was present and did not match the"
   272                              " its issuer name and serial number was present and did not match the"
   273                                                " authority key identifier of the current certificate"));
   273                              " authority key identifier of the current certificate");
   274         break;
   274         break;
   275     case NoPeerCertificate:
   275     case NoPeerCertificate:
   276         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "The peer did not present any certificate"));
   276         errStr = QSslSocket::tr("The peer did not present any certificate");
   277         break;
   277         break;
   278     case HostNameMismatch:
   278     case HostNameMismatch:
   279         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError,
   279         errStr = QSslSocket::tr("The host name did not match any of the valid hosts"
   280                                                "The host name did not match any of the valid hosts"
   280                              " for this certificate");
   281                                                " for this certificate"));
       
   282         break;
   281         break;
   283     case NoSslSupport:
   282     case NoSslSupport:
   284         break;
   283         break;
   285     default:
   284     default:
   286         errStr = QObject::tr(QT_TRANSLATE_NOOP(QSslError, "Unknown error"));
   285         errStr = QSslSocket::tr("Unknown error");
   287         break;
   286         break;
   288     }
   287     }
   289 
   288 
   290     return errStr;
   289     return errStr;
   291 }
   290 }