QSslCertificate Class
The QSslCertificate class holds an X.509 certificate. More…
| Header | #include <QSslCertificate> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Network) |
| Module | Nt Network C++ Classes |
List of all members, including inherited members
Public Types
| enum | SubjectInfo |
Public Functions
| QSslCertificate(const QByteArray &data = QByteArray(), QSsl::EncodingFormat format = QSsl::Pem) | |
| QSslCertificate(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem) | |
| bool | isNull() const |
| void | clear() |
| bool | isSelfSigned() const |
| QByteArray | version() const |
| QByteArray | serialNumber() const |
| QByteArray | digest(QCryptographicHash::Algorithm algorithm = QCryptographicHash::Md5) const |
| QStringList | issuerInfo(SubjectInfo info) const |
| QStringList | subjectInfo(SubjectInfo info) const |
| QString | issuerDisplayName() const |
| QString | subjectDisplayName() const |
| QMultiMap<QSsl::AlternativeNameEntryType, QString> | subjectAlternativeNames() const |
| QDateTime | effectiveDate() const |
| QDateTime | expiryDate() const |
| QByteArray | toPem() const |
| QByteArray | toDer() const |
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.
| Constant | Description |
|---|---|
QSslCertificate::Organization | The organization. |
QSslCertificate::CommonName | The common name. |
QSslCertificate::LocalityName | The locality. |
QSslCertificate::OrganizationalUnitName | The organizational unit. |
QSslCertificate::CountryName | The country. |
QSslCertificate::StateOrProvinceName | The state or province. |
QSslCertificate::DistinguishedNameQualifier | The distinguished name qualifier. |
QSslCertificate::SerialNumber | The subject serial number. |
QSslCertificate::EmailAddress | The email address. |
Member Function Documentation
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().
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().
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().
QList<QSslCertificate> QSslCertificate::fromDevice(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem)
Returns the certificates read from device, in the given format.
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.