6.0.0-rc4Source

QSslCertificate Class

The QSslCertificate class holds an X.509 certificate. More…

Header#include <QSslCertificate>
CMaketarget_link_libraries(app PRIVATE Nt::Network)
ModuleNt Network C++ Classes

List of all members, including inherited members

Public Types

Public Functions

Static Public Members

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

Detailed Description

const auto certificates = QSslCertificate::fromPath("server.pem");
qDebug() << certificates.first().subjectDisplayName();

See also QSslKey and QSslConfiguration.

Differences from Qt

There is no verify(), isBlacklisted(), extensions(), publicKey(), toText() or PKCS#12 import. fromPath() takes a single file, not a wildcard pattern.

Member Type Documentation

enum QSslCertificate::SubjectInfo

Selects a field of a certificate's subject or issuer.

ConstantDescription
QSslCertificate::OrganizationThe organization.
QSslCertificate::CommonNameThe common name.
QSslCertificate::LocalityNameThe locality.
QSslCertificate::OrganizationalUnitNameThe organizational unit.
QSslCertificate::CountryNameThe country.
QSslCertificate::StateOrProvinceNameThe state or province.
QSslCertificate::DistinguishedNameQualifierThe distinguished name qualifier.
QSslCertificate::SerialNumberThe subject serial number.
QSslCertificate::EmailAddressThe email address.

Member Function Documentation

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

Constructs a certificate by parsing data in the given format. If data is empty or invalid, the certificate is null.

See also isNull().

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

This is an overloaded function.

Constructs a certificate from the contents of device, in the given format.

void QSslCertificate::clear()

Makes the certificate null.

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

Returns the hash of the certificate, computed with algorithm.

QDateTime QSslCertificate::effectiveDate() const

Returns the time from which the certificate is valid, in UTC.

See also expiryDate().

QDateTime QSslCertificate::expiryDate() const

Returns the time at which the certificate stops being valid, in UTC.

See also effectiveDate().

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

Returns the certificates in data, in the given format. PEM data may hold several.

See also fromPath().

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

Returns the certificates read from device, in the given format.

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

Returns the certificates in the file path, in the given format.

See also fromData().

bool QSslCertificate::isNull() const

Returns true if no certificate is held.

bool QSslCertificate::isSelfSigned() const

Returns true if the certificate is its own issuer.

QString QSslCertificate::issuerDisplayName() const

Returns a name for showing the issuer.

See also subjectDisplayName().

QStringList QSslCertificate::issuerInfo(SubjectInfo info) const

Returns the values of the issuer's info field.

See also subjectInfo().

QByteArray QSslCertificate::serialNumber() const

Returns the serial number as colon-separated hex.

QMultiMap<QSsl::AlternativeNameEntryType, QString> QSslCertificate::subjectAlternativeNames() const

Returns the alternative names the certificate is valid for.

QString QSslCertificate::subjectDisplayName() const

Returns a name for showing the subject.

See also issuerDisplayName().

QStringList QSslCertificate::subjectInfo(SubjectInfo info) const

Returns the values of the subject's info field.

See also issuerInfo().

QByteArray QSslCertificate::toDer() const

Returns the certificate in DER format.

See also toPem().

QByteArray QSslCertificate::toPem() const

Returns the certificate in PEM format.

See also toDer().

QByteArray QSslCertificate::version() const

Returns the X.509 version, such as 3.