本文整理汇总了C++中QSslCertificate::alternateSubjectNames方法的典型用法代码示例。如果您正苦于以下问题:C++ QSslCertificate::alternateSubjectNames方法的具体用法?C++ QSslCertificate::alternateSubjectNames怎么用?C++ QSslCertificate::alternateSubjectNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSslCertificate
的用法示例。
在下文中一共展示了QSslCertificate::alternateSubjectNames方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCert
void CertView::setCert(const QList<QSslCertificate> &cert) {
qlCert = cert;
if (qlCert.isEmpty()) {
qlSubjectName->setText(QString());
qlSubjectEmail->setText(QString());
qlIssuerName->setText(QString());
} else {
QSslCertificate qscCert = qlCert.at(0);
QStringList emails(qscCert.alternateSubjectNames().values(QSsl::EmailEntry));
const QString &name = qscCert.subjectInfo(QSslCertificate::CommonName);
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("<br />")));
else
qlSubjectEmail->setText(tr("(none)"));
if (qlCert.count() > 1)
qscCert = qlCert.last();
const QString &issuer = qscCert.issuerInfo(QSslCertificate::CommonName);
qlIssuerName->setText((issuer == name) ? tr("Self-signed") : issuer);
}
}
示例2: certToFormattedString
static QString certToFormattedString(QSslCertificate cert)
{
QString resultstring = QLatin1String("<p>");
QStringList tmplist;
resultstring += cert.subjectInfo(QSslCertificate::CommonName);
resultstring += QString::fromLatin1("<br/>Issuer: %1")
.arg(cert.issuerInfo(QSslCertificate::CommonName));
resultstring += QString::fromLatin1("<br/>Not valid before: %1<br/>Valid Until: %2")
.arg(cert.effectiveDate().toString(Qt::ISODate))
.arg(cert.expiryDate().toString(Qt::ISODate));
QMultiMap<QSsl::AlternateNameEntryType, QString> names = cert.alternateSubjectNames();
if (names.count() > 0) {
tmplist = names.values(QSsl::DnsEntry);
resultstring += QLatin1String("<br/>Alternate Names:<ul><li>")
+ tmplist.join(QLatin1String("</li><li>"))
+ QLatin1String("</li><</ul>");
}
resultstring += QLatin1String("</p>");
return resultstring;
}
示例3: 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);
}
}
示例4:
QDebug operator<<(QDebug debug, const QSslCertificate &certificate)
{
debug << "QSslCertificate("
<< certificate.version()
<< "," << certificate.serialNumber()
<< "," << certificate.digest()
<< "," << certificate.issuerInfo(QSslCertificate::Organization)
<< "," << certificate.subjectInfo(QSslCertificate::Organization)
<< "," << certificate.alternateSubjectNames()
#ifndef QT_NO_TEXTSTREAM
<< "," << certificate.effectiveDate()
<< "," << certificate.expiryDate()
#endif
<< ")";
return debug;
}
示例5: dumpCertificate
void Connector::dumpCertificate( const QSslCertificate &cert )
{
qDebug() << cert.toPem();
qDebug() << "== Subject Info ==\b";
qDebug() << "CommonName:\t\t" << cert.subjectInfo( QSslCertificate::CommonName );
qDebug() << "Organization:\t\t" << cert.subjectInfo( QSslCertificate::Organization );
qDebug() << "LocalityName:\t\t" << cert.subjectInfo( QSslCertificate::LocalityName );
qDebug() << "OrganizationalUnitName:\t" << cert.subjectInfo( QSslCertificate::OrganizationalUnitName );
qDebug() << "StateOrProvinceName:\t" << cert.subjectInfo( QSslCertificate::StateOrProvinceName );
QMultiMap<QSsl::AlternateNameEntryType, QString> altNames = cert.alternateSubjectNames();
if ( !altNames.isEmpty() ) {
qDebug() << "Alternate Subject Names (DNS):";
foreach (const QString &altName, altNames.values(QSsl::DnsEntry)) {
qDebug() << altName;
}
qDebug() << "Alternate Subject Names (Email):";
foreach (const QString &altName, altNames.values(QSsl::EmailEntry)) {
qDebug() << altName;
}
}