本文整理汇总了C++中QSslCertificate::issuerInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ QSslCertificate::issuerInfo方法的具体用法?C++ QSslCertificate::issuerInfo怎么用?C++ QSslCertificate::issuerInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSslCertificate
的用法示例。
在下文中一共展示了QSslCertificate::issuerInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: foreach
// find trust anchor (informational only, verification is done by QSslSocket!)
foreach(QSslCertificate rootCA, QSslSocket::systemCaCertificates()) {
if (rootCA.issuerInfo(QSslCertificate::CommonName) == chain.last().issuerInfo(QSslCertificate::CommonName) &&
rootCA.issuerInfo(QSslCertificate::Organization) == chain.last().issuerInfo(QSslCertificate::Organization)) {
chain.append(rootCA);
break;
}
}
示例2: issuerInfo
// same here
QString SslInfoDlg::issuerInfo(const QSslCertificate &cert, QSslCertificate::SubjectInfo subjectInfo) const
{
#if QT_VERSION < 0x050000
return cert.issuerInfo(subjectInfo);
#else
return cert.issuerInfo(subjectInfo).join(", ");
#endif
}
示例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: addClientCertToTable
void PreferencesDialog::addClientCertToTable(const QString& path, const QSslCertificate& cert)
{
// Do nothing if the file doesn't even exist
if(!QFile::exists(path))
return;
// Add new row
int row = ui->tableClientCerts->rowCount();
ui->tableClientCerts->setRowCount(row + 1);
// Fill row with data
QTableWidgetItem* cert_file = new QTableWidgetItem(path);
cert_file->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 0, cert_file);
QTableWidgetItem* cert_subject_cn = new QTableWidgetItem(cert.subjectInfo(QSslCertificate::CommonName).at(0));
cert_subject_cn->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 1, cert_subject_cn);
QTableWidgetItem* cert_issuer_cn = new QTableWidgetItem(cert.issuerInfo(QSslCertificate::CommonName).at(0));
cert_issuer_cn->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 2, cert_issuer_cn);
QTableWidgetItem* cert_from = new QTableWidgetItem(cert.effectiveDate().toString());
cert_from->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 3, cert_from);
QTableWidgetItem* cert_to = new QTableWidgetItem(cert.expiryDate().toString());
cert_to->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 4, cert_to);
QTableWidgetItem* cert_serialno = new QTableWidgetItem(QString(cert.serialNumber()));
cert_serialno->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
ui->tableClientCerts->setItem(row, 5, cert_serialno);
}
示例5: 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);
}
}
示例6: 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;
}
示例7: getCertificateString
QString clientController::getCertificateString(const QSslCertificate &cert)
{
QString certInfo;
certInfo += "Issuer Org: ";
certInfo += cert.issuerInfo(QSslCertificate::Organization).join(" ") + QString("\n");
certInfo += "Common Name: ";
certInfo += cert.issuerInfo(QSslCertificate::CommonName).join(" ") + "\n";
certInfo += "Effective Date: ";
certInfo += cert.effectiveDate().toString() + "\n";
certInfo += "Expiry Date: ";
certInfo += cert.expiryDate().toString() + "\n";
certInfo += "Public Key: ";
certInfo += cert.publicKey().toPem() + "\n";
certInfo += "Serial Number: ";
certInfo += cert.serialNumber() + "\n";
return certInfo;
}
示例8: parseResult
void ResultParser::parseResult(const QUrl &originalUrl,
const QUrl &urlWithCertificate,
const QList<QSslCertificate> &certificateChain) {
Result currentResult = m_results.value(urlWithCertificate);
if (currentResult.sitesContainingLink.empty()) { // first time we encounter this site
QSslCertificate lastCertInChain = certificateChain.last();
currentResult.siteCertCountry = certificateChain.first().subjectInfo(QSslCertificate::CountryName).join(" / ");
currentResult.rootCertCountry = lastCertInChain.issuerInfo(QSslCertificate::CountryName).join(" / ");
currentResult.rootCertOrganization =
lastCertInChain.issuerInfo(QSslCertificate::Organization).join(" / ");
}
if (!currentResult.sitesContainingLink.contains(originalUrl)) {
currentResult.sitesContainingLink.insert(originalUrl);
m_results.insert(urlWithCertificate, currentResult);
}
}
示例9: onSslErrors
void Pastebin::onSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
{
QStringList ignoreCerts = AppSettings::instance()->ignoreErrorCerts();
QList<QSslError> ignoreErrors;
QList<QSslError> promptErrors;
QSslCertificate cert;
QStringList errorStrings;
foreach(const QSslError &error, errors) {
if(ignoreCerts.contains(QString(error.certificate().serialNumber()))) {
ignoreErrors.append(error);
}
else {
promptErrors.append(error);
if(cert.isNull()) {
cert = error.certificate();
}
errorStrings << error.errorString();
}
}
if(!ignoreErrors.isEmpty()) {
reply->ignoreSslErrors(ignoreErrors);
}
if(!promptErrors.isEmpty()) {
QString bodyText = tr(
"Issued to: %1\n"
"Serial number: %2\n"
"Issued by: %3\n"
"Effective: %4\n"
"Expires: %5\n"
"\n%6\n\n"
"Ignore this error?")
.arg(cert.subjectInfo(QSslCertificate::CommonName))
.arg(QString(cert.serialNumber()))
.arg(cert.issuerInfo(QSslCertificate::CommonName))
.arg(cert.effectiveDate().toLocalTime().toString(Qt::SystemLocaleShortDate))
.arg(cert.expiryDate().toLocalTime().toString(Qt::SystemLocaleShortDate))
.arg(errorStrings.join("\n"));
bb::system::SystemDialog dialog(tr("Yes"), tr("Always"), tr("No"));
dialog.setTitle(tr("SSL Error"));
dialog.setBody(bodyText);
bb::system::SystemUiResult::Type result = dialog.exec();
if(result == bb::system::SystemUiResult::ConfirmButtonSelection
|| result == bb::system::SystemUiResult::CustomButtonSelection) {
reply->ignoreSslErrors(promptErrors);
if(result == bb::system::SystemUiResult::CustomButtonSelection) {
ignoreCerts << QString(cert.serialNumber());
AppSettings::instance()->setIgnoreErrorCerts(ignoreCerts);
}
}
}
}
示例10: getCertificateString
QString Client::getCertificateString(const QSslCertificate &cert)
{
// Grab the fields and append to certInfo
QString certInfo;
certInfo += "Issuer Org: ";
certInfo += cert.issuerInfo(QSslCertificate::Organization) + "\n";
certInfo += "Common Name: ";
certInfo += cert.issuerInfo(QSslCertificate::CommonName) + "\n";
certInfo += "Effective Date: ";
certInfo += cert.effectiveDate().toString() + "\n";
certInfo += "Expiry Date: ";
certInfo += cert.expiryDate().toString() + "\n";
certInfo += "Public Key: ";
certInfo += cert.publicKey().toPem() + "\n";
certInfo += "Serial Number: ";
certInfo += cert.serialNumber() + "\n";
return certInfo;
}
示例11: QWidget
CertificateInfoWidget::CertificateInfoWidget(const QSslCertificate &cert, QWidget* parent)
: QWidget(parent)
, ui(new Ui::CertificateInfoWidget)
{
ui->setupUi(this);
//Issued to
ui->issuedToCN->setText(showCertInfo(cert.subjectInfo(QSslCertificate::CommonName)));
ui->issuedToO->setText(showCertInfo(cert.subjectInfo(QSslCertificate::Organization)));
ui->issuedToOU->setText(showCertInfo(cert.subjectInfo(QSslCertificate::OrganizationalUnitName)));
ui->issuedToSN->setText(showCertInfo(cert.serialNumber()));
//Issued By
ui->issuedByCN->setText(showCertInfo(cert.issuerInfo(QSslCertificate::CommonName)));
ui->issuedByO->setText(showCertInfo(cert.issuerInfo(QSslCertificate::Organization)));
ui->issuedByOU->setText(showCertInfo(cert.issuerInfo(QSslCertificate::OrganizationalUnitName)));
//Validity
ui->validityIssuedOn->setText(cert.effectiveDate().toString("dddd d. MMMM yyyy"));
ui->validityExpiresOn->setText(cert.expiryDate().toString("dddd d. MMMM yyyy"));
}
示例12: isBlacklisted
bool QSslCertificatePrivate::isBlacklisted(const QSslCertificate &certificate)
{
for (int a = 0; certificate_blacklist[a] != 0; a++) {
QString blacklistedCommonName = QString::fromUtf8(certificate_blacklist[(a+1)]);
if (certificate.serialNumber() == certificate_blacklist[a++] &&
(certificate.subjectInfo(QSslCertificate::CommonName).contains(blacklistedCommonName) ||
certificate.issuerInfo(QSslCertificate::CommonName).contains(blacklistedCommonName)))
return true;
}
return false;
}
示例13: setCurrentCert
void SslInfoDlg::setCurrentCert(int index)
{
QSslCertificate cert = socket()->peerCertificateChain().at(index);
ui.subjectCommonName->setText(cert.subjectInfo(QSslCertificate::CommonName));
ui.subjectOrganization->setText(cert.subjectInfo(QSslCertificate::Organization));
ui.subjectOrganizationalUnit->setText(cert.subjectInfo(QSslCertificate::OrganizationalUnitName));
ui.subjectCountry->setText(cert.subjectInfo(QSslCertificate::CountryName));
ui.subjectState->setText(cert.subjectInfo(QSslCertificate::StateOrProvinceName));
ui.subjectCity->setText(cert.subjectInfo(QSslCertificate::LocalityName));
ui.issuerCommonName->setText(cert.issuerInfo(QSslCertificate::CommonName));
ui.issuerOrganization->setText(cert.issuerInfo(QSslCertificate::Organization));
ui.issuerOrganizationalUnit->setText(cert.issuerInfo(QSslCertificate::OrganizationalUnitName));
ui.issuerCountry->setText(cert.issuerInfo(QSslCertificate::CountryName));
ui.issuerState->setText(cert.issuerInfo(QSslCertificate::StateOrProvinceName));
ui.issuerCity->setText(cert.issuerInfo(QSslCertificate::LocalityName));
if (socket()->sslErrors().isEmpty())
ui.trusted->setText(tr("Yes"));
else {
QString errorString = tr("No, for the following reasons:<ul>");
foreach(const QSslError &error, socket()->sslErrors())
errorString += "<li>" + error.errorString() + "</li>";
errorString += "</ul>";
ui.trusted->setText(errorString);
}
ui.validity->setText(tr("%1 to %2").arg(cert.effectiveDate().date().toString(Qt::ISODate), cert.expiryDate().date().toString(Qt::ISODate)));
ui.md5Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Md5)));
ui.sha1Digest->setText(prettyDigest(cert.digest(QCryptographicHash::Sha1)));
}
示例14: dumpCertificate
QString dumpCertificate(const QSslCertificate &cert)
{
if (cert.isNull())
return "\n-\n";
QString s = "\n";
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
s += cert.toText();
#else
QString s_none = QObject::tr("<Not Part of Certificate>");
#define CERTIFICATE_STR(x) ( ((x) == "" ) ? s_none : (x) )
s += "Certificate:\n";
s += "\nIssued To:\n";
s += "CommonName(CN): " + CERTIFICATE_STR(cert.subjectInfo(QSslCertificate::CommonName)) + "\n";
s += "Organization(O): " + CERTIFICATE_STR(cert.subjectInfo(QSslCertificate::Organization)) + "\n";
s += "OrganizationalUnitName(OU): " + CERTIFICATE_STR(cert.subjectInfo(QSslCertificate::OrganizationalUnitName)) + "\n";
s += "Serial Number: " + dumpHexPresentation(cert.serialNumber()) + "\n";
s += "\nIssued By:\n";
s += "CommonName(CN): " + CERTIFICATE_STR(cert.issuerInfo(QSslCertificate::CommonName)) + "\n";
s += "Organization(O): " + CERTIFICATE_STR(cert.issuerInfo(QSslCertificate::Organization)) + "\n";
s += "OrganizationalUnitName(OU): " + CERTIFICATE_STR(cert.issuerInfo(QSslCertificate::OrganizationalUnitName)) + "\n";
s += "\nPeriod Of Validity\n";
s += "Begins On: " + cert.effectiveDate().toString() + "\n";
s += "Expires On: " + cert.expiryDate().toString() + "\n";
s += "IsValid: " + (cert.isValid() ? QString("Yes") : QString("No")) + "\n";
s += "\nFingerprints\n";
s += "SHA1 Fingerprint:\n" + dumpCertificateFingerprint(cert, QCryptographicHash::Sha1) + "\n";
s += "MD5 Fingerprint:\n" + dumpCertificateFingerprint(cert, QCryptographicHash::Md5) + "\n";
#endif
s += "\n\n";
s += cert.toPem();
return s;
}
示例15: nonemptyIssuer
static QString nonemptyIssuer(const QSslCertificate &cert)
{
QString issuerText;
static const QSslCertificate::SubjectInfo fields[3] = {
QSslCertificate::Organization,
QSslCertificate::CommonName,
QSslCertificate::OrganizationalUnitName
};
QStringList info;
for (int i = 0; i < 3; i++) {
info = cert.issuerInfo(fields[i]);
if (!info.isEmpty()) {
issuerText = cert.issuerInfo(fields[i]).join(',');
if (!issuerText.isEmpty()) {
return issuerText;
}
}
}
return issuerText;
}