本文整理汇总了C++中QSslCertificate::publicKey方法的典型用法代码示例。如果您正苦于以下问题:C++ QSslCertificate::publicKey方法的具体用法?C++ QSslCertificate::publicKey怎么用?C++ QSslCertificate::publicKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSslCertificate
的用法示例。
在下文中一共展示了QSslCertificate::publicKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: verifyPackage
bool InstallChecker::verifyPackage( const QString &filePath, bool )
{
QProcess proc;
proc.start( "hdiutil", QStringList() << "verify" << filePath );
proc.waitForFinished();
if( proc.exitCode() )
return false;
QString path = mountPackage( filePath );
if( path.isEmpty() )
return false;
xar_t xar = xar_open( path.toUtf8().constData(), 0 );
if( !xar )
return false;
QSslCertificate cert;
xar_signature_t sig = xar_signature_first( xar );
int32_t count = xar_signature_get_x509certificate_count( sig );
for( int32_t i = 0; i < count; ++i )
{
uint32_t size = 0;
const uint8_t *data = 0;
if( xar_signature_get_x509certificate_data( sig, i, &data, &size ) )
continue;
QSslCertificate c( QByteArray( (const char*)data, size ), QSsl::Der );
#if QT_VERSION >= 0x050000
QString cn = c.subjectInfo( QSslCertificate::CommonName ).value(0);
#else
QString cn = c.subjectInfo( QSslCertificate::CommonName );
#endif
if( cn == "Estonian Informatics Centre" ||
cn == "Developer ID Installer: Riigi Infosüsteemi Amet" )
cert = c;
}
if( cert.isNull() )
{
xar_close( xar );
return false;
}
uint8_t *data = 0, *signature = 0;
uint32_t dataSize = 0, signatureSize = 0;
off_t offset = 0;
if( xar_signature_copy_signed_data( sig, &data, &dataSize, &signature, &signatureSize, &offset ) )
{
xar_close( xar );
return false;
}
int result = RSA_verify( NID_sha1, data, dataSize, signature, signatureSize, (RSA*)cert.publicKey().handle() );
xar_close( xar );
free( data );
free( signature );
return result;
}
示例2: 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;
}
示例3: 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;
}