Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QSslCertificate Class Reference
[QtNetwork module]

The QSslCertificate class provides a convenient API for an X509 certificate. More...

 #include <QSslCertificate>

This class is not part of the Qt GUI Framework Edition.

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.3.


Public Types

enum SubjectInfo { Organization, CommonName, LocalityName, OrganizationalUnitName, CountryName, StateOrProvinceName }

Public Functions

QSslCertificate ( QIODevice * device, QSsl::EncodingFormat format = QSsl::Pem )
QSslCertificate ( const QByteArray & data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem )
QSslCertificate ( const QSslCertificate & other )
~QSslCertificate ()
QMultiMap<QSsl::AlternateNameEntryType, QString> alternateSubjectNames () const
void clear ()
QByteArray digest ( QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5 ) const
QDateTime effectiveDate () const
QDateTime expiryDate () const
Qt::HANDLE handle () const
bool isNull () const
bool isValid () const
QString issuerInfo ( SubjectInfo subject ) const
QString issuerInfo ( const QByteArray & tag ) const
QSslKey publicKey () const
QByteArray serialNumber () const
QString subjectInfo ( SubjectInfo subject ) const
QString subjectInfo ( const QByteArray & tag ) const
QByteArray toDer () const
QByteArray toPem () const
QByteArray version () const
bool operator!= ( const QSslCertificate & other ) const
QSslCertificate & operator= ( const QSslCertificate & other )
bool operator== ( const QSslCertificate & other ) const

Static Public Members

QList<QSslCertificate> fromData ( const QByteArray & data, QSsl::EncodingFormat format = QSsl::Pem )
QList<QSslCertificate> fromDevice ( QIODevice * device, QSsl::EncodingFormat format = QSsl::Pem )
QList<QSslCertificate> fromPath ( const QString & path, QSsl::EncodingFormat format = QSsl::Pem, QRegExp::PatternSyntax syntax = QRegExp::FixedString )

Detailed Description

The QSslCertificate class provides a convenient API for an X509 certificate.

QSslCertificate stores an X509 certificate, and is commonly used to verify the identity and store information about the local host, a remotely connected peer, or a trusted third party Certificate Authority.

There are many ways to construct a QSslCertificate. The most common way is to call QSslSocket::peerCertificate(), which returns a QSslCertificate object, or QSslSocket::peerCertificateChain(), which returns a list of them. You can also load certificates from a DER (binary) or PEM (Base64) encoded bundle, typically stored as one or more local files, or in a Qt Resource.

You can call isNull() to check if your certificate is null. By default, QSslCertificate constructs a null certificate. To check if the certificate is valid, call isValid(). A null certificate is invalid, but an invalid certificate is not necessarily null. If you want to reset all contents in a certificate, call clear().

After loading a certificate, you can find information about the certificate, its subject, and its issuer, by calling one of the many accessor functions, including version(), serialNumber(), issuerInfo() and subjectInfo(). You can call effectiveDate() and expiryDate() to check when the certificate starts being effective and when it expires. The publicKey() function returns the certificate subject's public key as a QSslKey. You can call issuerInfo() or subjectInfo() to get detailed information about the certificate issuer and its subject.

Internally, QSslCertificate is stored as an X509 structure. You can access this handle by calling handle(), but the results are likely to not be portable.

See also QSslSocket, QSslKey, QSslCipher, and QSslError.


Member Type Documentation

enum QSslCertificate::SubjectInfo

Describes keys that you can pass to QSslCertificate::issuerInfo() or QSslCertificate::subjectInfo() to get information about the certificate issuer or subject.

ConstantValueDescription
QSslCertificate::Organization0"O" The name of the organization.
QSslCertificate::CommonName1"CN" The common name; most often this is used to store the host name.
QSslCertificate::LocalityName2"L" The locality.
QSslCertificate::OrganizationalUnitName3"OU" The organizational unit name.
QSslCertificate::CountryName4"C" The country.
QSslCertificate::StateOrProvinceName5"ST" The state or province.


Member Function Documentation

QSslCertificate::QSslCertificate ( QIODevice * device, QSsl::EncodingFormat format = QSsl::Pem )

Constructs a QSslCertificate by reading format encoded data from device and using the first certificate found. You can later call isNull() to see if device contained a certificate, and if this certificate was loaded successfully.

QSslCertificate::QSslCertificate ( const QByteArray & data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem )

Constructs a QSslCertificate by parsing the format encoded data and using the first available certificate found. You can later call isNull() to see if data contained a certificate, and if this certificate was loaded successfully.

QSslCertificate::QSslCertificate ( const QSslCertificate & other )

Constructs an identical copy of other.

QSslCertificate::~QSslCertificate ()

Destroys the QSslCertificate.

QMultiMap<QSsl::AlternateNameEntryType, QString> QSslCertificate::alternateSubjectNames () const

Returns the list of alternative subject names for this certificate. The alternate subject names typically contain host names, optionally with wildcards, that are valid for this certificate.

These names are tested against the connected peer's host name, if either the subject information for CommonName doesn't define a valid host name, or the subject info name doesn't match the peer's host name.

See also subjectInfo().

void QSslCertificate::clear ()

Clears the contents of this certificate, making it a null certificate.

See also isNull().

QByteArray QSslCertificate::digest ( QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5 ) const

Returns a cryptographic digest of this certificate. By default, an MD5 digest will be generated, but you can also specify a custom algorithm.

QDateTime QSslCertificate::effectiveDate () const

Returns the date-time that the certificate becomes valid, or an empty QDateTime if this is a null certificate.

See also expiryDate().

QDateTime QSslCertificate::expiryDate () const

Returns the date-time that the certificate expires, or an empty QDateTime if this is a null certificate.

See also effectiveDate().

QList<QSslCertificate> QSslCertificate::fromData ( const QByteArray & data, QSsl::EncodingFormat format = QSsl::Pem )   [static]

Searches for and parses all certificates in data that are encoded in the specified format and returns them in a list of certificates.

See also fromDevice().

QList<QSslCertificate> QSslCertificate::fromDevice ( QIODevice * device, QSsl::EncodingFormat format = QSsl::Pem )   [static]

Searches for and parses all certificates in device that are encoded in the specified format and returns them in a list of certificates.

See also fromData().

QList<QSslCertificate> QSslCertificate::fromPath ( const QString & path, QSsl::EncodingFormat format = QSsl::Pem, QRegExp::PatternSyntax syntax = QRegExp::FixedString )   [static]

Searches all files in the path for certificates encoded in the specified format and returns them in a list. must be a file or a pattern matching one or more files, as specified by syntax.

Example:

 foreach (QSslCertificate cert, QSslCertificate::fromPath("C:/ssl/certificate.*.pem", QSsl::Pem,
                                                          QRegExp::Wildcard)) {
     qDebug() << cert.issuerInfo(QSslCertificate::Organization);
 }

See also fromData().

Qt::HANDLE QSslCertificate::handle () const

Returns a pointer to the native certificate handle, if there is one, or a null pointer otherwise.

You can use this handle, together with the native API, to access extended information about the certificate.

Warning: Use of this function has a high probability of being non-portable, and its return value may vary from platform to platform or change from minor release to minor release.

bool QSslCertificate::isNull () const

Returns true if this is a null certificate (i.e., a certificate with no contents); otherwise returns false.

By default, QSslCertificate constructs a null certificate.

See also isValid() and clear().

bool QSslCertificate::isValid () const

Returns true if this certificate is valid; otherwise returns false.

Note: Currently, this function only checks that the current data-time is within the date-time range during which the certificate is considered valid. No other checks are currently performed.

See also isNull().

QString QSslCertificate::issuerInfo ( SubjectInfo subject ) const

Returns the issuer information for the subject from the certificate, or an empty string if there is no information for subject in the certificate.

See also subjectInfo().

QString QSslCertificate::issuerInfo ( const QByteArray & tag ) const

Returns the issuer information for tag from the certificate, or an empty string if there is no information for tag in the certificate.

See also subjectInfo().

QSslKey QSslCertificate::publicKey () const

Returns the certificate subject's public key.

QByteArray QSslCertificate::serialNumber () const

Returns the certificate's serial number string in decimal format.

QString QSslCertificate::subjectInfo ( SubjectInfo subject ) const

Returns the information for the subject, or an empty string if there is no information for subject in the certificate.

See also issuerInfo().

QString QSslCertificate::subjectInfo ( const QByteArray & tag ) const

Returns the subject information for tag, or an empty string if there is no information for tag in the certificate.

See also issuerInfo().

QByteArray QSslCertificate::toDer () const

Returns this certificate converted to a DER (binary) encoded representation.

QByteArray QSslCertificate::toPem () const

Returns this certificate converted to a PEM (Base64) encoded representation.

QByteArray QSslCertificate::version () const

Returns the certificate's version string.

bool QSslCertificate::operator!= ( const QSslCertificate & other ) const

Returns true if this certificate is not the same as other; otherwise returns false.

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

Copies the contents of other into this certificate, making the two certificates identical.

bool QSslCertificate::operator== ( const QSslCertificate & other ) const

Returns true if this certificate is the same as other; otherwise returns false.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 56
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 90
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 31
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 231
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.6-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web