本文整理汇总了C++中QSslCertificate::subjectAlternativeNames方法的典型用法代码示例。如果您正苦于以下问题:C++ QSslCertificate::subjectAlternativeNames方法的具体用法?C++ QSslCertificate::subjectAlternativeNames怎么用?C++ QSslCertificate::subjectAlternativeNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSslCertificate
的用法示例。
在下文中一共展示了QSslCertificate::subjectAlternativeNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCert
void CertView::setCert(const QList<QSslCertificate> &cert) {
qlCert = cert;
if (qlCert.isEmpty()) {
qlSubjectName->setText(QString());
qlSubjectEmail->setText(QString());
qlIssuerName->setText(QString());
qlExpiry->setText(QString());
} else {
QSslCertificate qscCert = qlCert.at(0);
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
const QStringList &names = qscCert.subjectInfo(QSslCertificate::CommonName);
QString name;
if (names.count() > 0) {
name = names.at(0);
}
QStringList emails = qscCert.subjectAlternativeNames().values(QSsl::EmailEntry);
#else
const QString &name = qscCert.subjectInfo(QSslCertificate::CommonName);
QStringList emails(qscCert.alternateSubjectNames().values(QSsl::EmailEntry));
#endif
QString tmpName = name;
tmpName = tmpName.replace(QLatin1String("\\x"), QLatin1String("%"));
tmpName = QUrl::fromPercentEncoding(tmpName.toLatin1());
qlSubjectName->setText(tmpName);
if (emails.count() > 0)
qlSubjectEmail->setText(emails.join(QLatin1String("\n")));
else
qlSubjectEmail->setText(tr("(none)"));
if (qscCert.expiryDate() <= QDateTime::currentDateTime())
qlExpiry->setText(QString::fromLatin1("<font color=\"red\"><b>%1</b></font>").arg(Qt::escape(qscCert.expiryDate().toString(Qt::SystemLocaleDate))));
else
qlExpiry->setText(qscCert.expiryDate().toString(Qt::SystemLocaleDate));
if (qlCert.count() > 1)
qscCert = qlCert.last();
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
const QStringList &issuerNames = qscCert.issuerInfo(QSslCertificate::CommonName);
QString issuerName;
if (issuerNames.count() > 0) {
issuerName = issuerName.at(0);
}
#else
const QString &issuerName = qscCert.issuerInfo(QSslCertificate::CommonName);
#endif
qlIssuerName->setText((issuerName == name) ? tr("Self-signed") : issuerName);
}
}
示例2:
QDebug operator<<(QDebug debug, const QSslCertificate &certificate)
{
debug << "QSslCertificate("
<< certificate.version()
<< ',' << certificate.serialNumber()
<< ',' << certificate.digest().toBase64()
<< ',' << certificate.issuerInfo(QSslCertificate::Organization)
<< ',' << certificate.subjectInfo(QSslCertificate::Organization)
<< ',' << certificate.subjectAlternativeNames()
#ifndef QT_NO_DATESTRING
<< ',' << certificate.effectiveDate()
<< ',' << certificate.expiryDate()
#endif
<< ')';
return debug;
}