Qt 4.8
Macros | Functions | Variables
qsslcertificate.cpp File Reference
#include "qsslsocket_openssl_symbols_p.h"
#include "qsslcertificate.h"
#include "qsslcertificate_p.h"
#include "qsslkey.h"
#include "qsslkey_p.h"
#include <QtCore/qatomic.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#include <QtCore/qdiriterator.h>
#include <QtCore/qfile.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qmap.h>
#include <QtCore/qmutex.h>
#include <QtCore/private/qmutexpool_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>

Go to the source code of this file.

Macros

#define BEGINCERTSTRING   "-----BEGIN CERTIFICATE-----"
 
#define ENDCERTSTRING   "-----END CERTIFICATE-----"
 

Functions

static QMap< QString, QString_q_mapFromX509Name (X509_NAME *name)
 
static QString _q_SubjectInfoToString (QSslCertificate::SubjectInfo info)
 
static bool matchLineFeed (const QByteArray &pem, int *offset)
 
QDebug operator<< (QDebug debug, const QSslCertificate &certificate)
 
QDebug operator<< (QDebug debug, QSslCertificate::SubjectInfo info)
 

Variables

static const char * certificate_blacklist []
 

Macro Definition Documentation

◆ BEGINCERTSTRING

#define BEGINCERTSTRING   "-----BEGIN CERTIFICATE-----"

◆ ENDCERTSTRING

#define ENDCERTSTRING   "-----END CERTIFICATE-----"

Function Documentation

◆ _q_mapFromX509Name()

static QMap< QString, QString > _q_mapFromX509Name ( X509_NAME *  name)
static

Definition at line 692 of file qsslcertificate.cpp.

Referenced by QSslCertificate::issuerInfo(), and QSslCertificate::subjectInfo().

693 {
695  for (int i = 0; i < q_X509_NAME_entry_count(name); ++i) {
696  X509_NAME_ENTRY *e = q_X509_NAME_get_entry(name, i);
698  unsigned char *data = 0;
700  info[QString::fromUtf8(obj)] = QString::fromUtf8((char*)data, size);
701  q_CRYPTO_free(data);
702  }
703  return info;
704 }
const char * q_OBJ_nid2sn(int a)
static mach_timebase_info_data_t info
const char * name
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
static const char * data(const QByteArray &arr)
ASN1_OBJECT * q_X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *a)
int q_OBJ_obj2nid(const ASN1_OBJECT *a)
int q_X509_NAME_entry_count(X509_NAME *a)
int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b)
ASN1_STRING * q_X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *a)
void q_CRYPTO_free(void *a)
X509_NAME_ENTRY * q_X509_NAME_get_entry(X509_NAME *a, int b)

◆ _q_SubjectInfoToString()

static QString _q_SubjectInfoToString ( QSslCertificate::SubjectInfo  info)
static

Definition at line 312 of file qsslcertificate.cpp.

Referenced by QSslCertificate::issuerInfo(), and QSslCertificate::subjectInfo().

313 {
314  QString str;
315  switch (info) {
316  case QSslCertificate::Organization: str = QLatin1String("O"); break;
317  case QSslCertificate::CommonName: str = QLatin1String("CN"); break;
318  case QSslCertificate::LocalityName: str = QLatin1String("L"); break;
320  case QSslCertificate::CountryName: str = QLatin1String("C"); break;
321  case QSslCertificate::StateOrProvinceName: str = QLatin1String("ST"); break;
322  }
323  return str;
324 }
static mach_timebase_info_data_t info
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83

◆ matchLineFeed()

static bool matchLineFeed ( const QByteArray pem,
int *  offset 
)
static

Definition at line 722 of file qsslcertificate.cpp.

Referenced by QSslCertificatePrivate::certificatesFromPem().

723 {
724  char ch = 0;
725 
726  // ignore extra whitespace at the end of the line
727  while (*offset < pem.size() && (ch = pem.at(*offset)) == ' ')
728  ++*offset;
729 
730  if (ch == '\n') {
731  *offset += 1;
732  return true;
733  }
734  if (ch == '\r' && pem.size() > (*offset + 1) && pem.at(*offset + 1) == '\n') {
735  *offset += 2;
736  return true;
737  }
738  return false;
739 }
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413

◆ operator<<() [1/2]

QDebug operator<< ( QDebug  debug,
const QSslCertificate certificate 
)

Definition at line 866 of file qsslcertificate.cpp.

867 {
868  debug << "QSslCertificate("
869  << certificate.version()
870  << ',' << certificate.serialNumber()
871  << ',' << certificate.digest().toBase64()
872  << ',' << certificate.issuerInfo(QSslCertificate::Organization)
873  << ',' << certificate.subjectInfo(QSslCertificate::Organization)
874  << ',' << certificate.alternateSubjectNames()
875 #ifndef QT_NO_TEXTSTREAM
876  << ',' << certificate.effectiveDate()
877  << ',' << certificate.expiryDate()
878 #endif
879  << ')';
880  return debug;
881 }
QByteArray serialNumber() const
Returns the certificate&#39;s serial number string in decimal format.
QString subjectInfo(SubjectInfo info) const
Returns the information for the subject, or an empty string if there is no information for subject in...
QString issuerInfo(SubjectInfo info) const
Returns the issuer information for the subject from the certificate, or an empty string if there is n...
QDateTime effectiveDate() const
Returns the date-time that the certificate becomes valid, or an empty QDateTime if this is a null cer...
QMultiMap< QSsl::AlternateNameEntryType, QString > alternateSubjectNames() const
Returns the list of alternative subject names for this certificate.
QByteArray version() const
Returns the certificate&#39;s version string.
QDateTime expiryDate() const
Returns the date-time that the certificate expires, or an empty QDateTime if this is a null certifica...
QByteArray digest(QCryptographicHash::Algorithm algorithm=QCryptographicHash::Md5) const
Returns a cryptographic digest of this certificate.
QByteArray toBase64() const
Returns a copy of the byte array, encoded as Base64.

◆ operator<<() [2/2]

QDebug operator<< ( QDebug  debug,
QSslCertificate::SubjectInfo  info 
)

Definition at line 882 of file qsslcertificate.cpp.

883 {
884  switch (info) {
885  case QSslCertificate::Organization: debug << "Organization"; break;
886  case QSslCertificate::CommonName: debug << "CommonName"; break;
887  case QSslCertificate::CountryName: debug << "CountryName"; break;
888  case QSslCertificate::LocalityName: debug << "LocalityName"; break;
889  case QSslCertificate::OrganizationalUnitName: debug << "OrganizationalUnitName"; break;
890  case QSslCertificate::StateOrProvinceName: debug << "StateOrProvinceName"; break;
891  }
892  return debug;
893 }
static mach_timebase_info_data_t info

Variable Documentation

◆ certificate_blacklist

const char* certificate_blacklist[]
static

Definition at line 808 of file qsslcertificate.cpp.

Referenced by QSslCertificatePrivate::isBlacklisted().