Qt 4.8
Classes | Macros | Functions
qsslsocket_openssl.cpp File Reference
#include "qsslsocket_openssl_p.h"
#include "qsslsocket_openssl_symbols_p.h"
#include "qsslsocket.h"
#include "qsslcertificate_p.h"
#include "qsslcipher_p.h"
#include <QtCore/qdatetime.h>
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#include <QtCore/qdiriterator.h>
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qmutex.h>
#include <QtCore/qthread.h>
#include <QtCore/qurl.h>
#include <QtCore/qvarlengtharray.h>
#include <QLibrary>

Go to the source code of this file.

Classes

class  QOpenSslLocks
 
struct  QSslErrorList
 

Macros

#define kSecTrustSettingsDomainSystem   2
 

Functions

static QSslError _q_OpenSSL_to_QSslError (int errorCode, const QSslCertificate &cert)
 
static unsigned long id_function ()
 
static void locking_function (int mode, int lockNumber, const char *, int)
 
static int q_X509Callback (int ok, X509_STORE_CTX *ctx)
 

Macro Definition Documentation

◆ kSecTrustSettingsDomainSystem

#define kSecTrustSettingsDomainSystem   2

Definition at line 73 of file qsslsocket_openssl.cpp.

Referenced by QSslSocketPrivate::systemCaCertificates().

Function Documentation

◆ _q_OpenSSL_to_QSslError()

static QSslError _q_OpenSSL_to_QSslError ( int  errorCode,
const QSslCertificate cert 
)
static

Definition at line 1205 of file qsslsocket_openssl.cpp.

Referenced by QSslSocketBackendPrivate::startHandshake().

1206 {
1207  QSslError error;
1208  switch (errorCode) {
1209  case X509_V_OK:
1210  // X509_V_OK is also reported if the peer had no certificate.
1211  break;
1212  case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
1213  error = QSslError(QSslError::UnableToGetIssuerCertificate, cert); break;
1214  case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
1216  case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
1218  case X509_V_ERR_CERT_SIGNATURE_FAILURE:
1219  error = QSslError(QSslError::CertificateSignatureFailed, cert); break;
1220  case X509_V_ERR_CERT_NOT_YET_VALID:
1221  error = QSslError(QSslError::CertificateNotYetValid, cert); break;
1222  case X509_V_ERR_CERT_HAS_EXPIRED:
1223  error = QSslError(QSslError::CertificateExpired, cert); break;
1224  case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
1225  error = QSslError(QSslError::InvalidNotBeforeField, cert); break;
1226  case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
1227  error = QSslError(QSslError::InvalidNotAfterField, cert); break;
1228  case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
1229  error = QSslError(QSslError::SelfSignedCertificate, cert); break;
1230  case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
1231  error = QSslError(QSslError::SelfSignedCertificateInChain, cert); break;
1232  case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
1234  case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
1236  case X509_V_ERR_CERT_REVOKED:
1237  error = QSslError(QSslError::CertificateRevoked, cert); break;
1238  case X509_V_ERR_INVALID_CA:
1239  error = QSslError(QSslError::InvalidCaCertificate, cert); break;
1240  case X509_V_ERR_PATH_LENGTH_EXCEEDED:
1241  error = QSslError(QSslError::PathLengthExceeded, cert); break;
1242  case X509_V_ERR_INVALID_PURPOSE:
1243  error = QSslError(QSslError::InvalidPurpose, cert); break;
1244  case X509_V_ERR_CERT_UNTRUSTED:
1245  error = QSslError(QSslError::CertificateUntrusted, cert); break;
1246  case X509_V_ERR_CERT_REJECTED:
1247  error = QSslError(QSslError::CertificateRejected, cert); break;
1248  default:
1249  error = QSslError(QSslError::UnspecifiedError, cert); break;
1250  }
1251  return error;
1252 }
#define error(msg)
The QSslError class provides an SSL error.
Definition: qsslerror.h:58

◆ id_function()

static unsigned long id_function ( )
static

Definition at line 167 of file qsslsocket_openssl.cpp.

Referenced by QSslSocketPrivate::ensureLibraryLoaded().

168 {
170 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
static Qt::HANDLE currentThreadId()
Returns the thread handle of the currently executing thread.

◆ locking_function()

static void locking_function ( int  mode,
int  lockNumber,
const char *  ,
int   
)
static

Definition at line 157 of file qsslsocket_openssl.cpp.

Referenced by QSslSocketPrivate::ensureLibraryLoaded().

158 {
159  QMutex *mutex = openssl_locks()->lock(lockNumber);
160 
161  // Lock or unlock it
162  if (mode & CRYPTO_LOCK)
163  mutex->lock();
164  else
165  mutex->unlock();
166 }
void lock()
Locks the mutex.
Definition: qmutex.cpp:151
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
void unlock()
Unlocks the mutex.
Definition: qmutex.cpp:296

◆ q_X509Callback()

static int q_X509Callback ( int  ok,
X509_STORE_CTX *  ctx 
)
static

Definition at line 236 of file qsslsocket_openssl.cpp.

Referenced by QSslSocketBackendPrivate::initSslContext().

237 {
238  if (!ok) {
239  // Store the error and at which depth the error was detected.
240  _q_sslErrorList()->errors << qMakePair<int, int>(q_X509_STORE_CTX_get_error(ctx), q_X509_STORE_CTX_get_error_depth(ctx));
241  }
242  // Always return OK to allow verification to continue. We're handle the
243  // errors gracefully after collecting all errors, after verification has
244  // completed.
245  return 1;
246 }
int q_X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx)
int q_X509_STORE_CTX_get_error(X509_STORE_CTX *ctx)
#define ctx
Definition: qgl.cpp:6094