本文整理汇总了C++中SslCertificate::toHex方法的典型用法代码示例。如果您正苦于以下问题:C++ SslCertificate::toHex方法的具体用法?C++ SslCertificate::toHex怎么用?C++ SslCertificate::toHex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SslCertificate
的用法示例。
在下文中一共展示了SslCertificate::toHex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s
CertificateDialog::CertificateDialog(const QSslCertificate &cert, QWidget *parent, bool removePath)
: QDialog( parent )
, d( new CertificateDialogPrivate )
{
d->setupUi( this );
QPushButton *save = d->buttonBox->button(QDialogButtonBox::Save);
if(save && Settings(QSettings::SystemScope).value("disableSave", false).toBool())
{
d->buttonBox->removeButton(save);
save->deleteLater();
}
if(removePath)
d->tabWidget->removeTab( 2 );
d->cert = cert;
SslCertificate c = cert;
QString i;
QTextStream s( &i );
s << "<b>" << tr("Certificate Information") << "</b><br />";
s << "<hr>";
s << "<b>" << tr("This certificate is intended for following purpose(s):") << "</b>";
s << "<ul>";
for(const QString &ext: c.enhancedKeyUsage())
s << "<li>" << ext << "</li>";
s << "</ul>";
s << "<br /><br /><br /><br />";
//s << tr("* Refer to the certification authority's statement for details.") << "<br />";
s << "<hr>";
s << "<p style='margin-left: 30px;'>";
s << "<b>" << tr("Issued to:") << "</b> " << c.subjectInfo( QSslCertificate::CommonName );
s << "<br /><br /><br />";
s << "<b>" << tr("Issued by:") << "</b> " << c.issuerInfo( QSslCertificate::CommonName );
s << "<br /><br /><br />";
s << "<b>" << tr("Valid from") << "</b> " << c.effectiveDate().toLocalTime().toString( "dd.MM.yyyy" ) << " ";
s << "<b>" << tr("to") << "</b> "<< c.expiryDate().toLocalTime().toString( "dd.MM.yyyy" );
s << "</p>";
d->info->setHtml( i );
d->addItem( tr("Version"), "V" + c.version() );
d->addItem( tr("Serial number"), QString( "%1 (0x%2)" )
.arg( c.serialNumber().constData() )
.arg( c.serialNumber( true ).constData() ) );
d->addItem( tr("Signature algorithm"), c.signatureAlgorithm() );
QStringList text, textExt;
for(const QByteArray &obj: c.issuerInfoAttributes())
{
const QString &data = c.issuerInfo( obj );
if( data.isEmpty() )
continue;
text << data;
textExt << QString( "%1 = %2" ).arg( obj.constData() ).arg( data );
}
d->addItem( tr("Issuer"), text.join( ", " ), textExt.join( "\n" ) );
d->addItem( tr("Valid from"), DateTime( c.effectiveDate().toLocalTime() ).toStringZ( "dd.MM.yyyy hh:mm:ss" ) );
d->addItem( tr("Valid to"), DateTime( c.expiryDate().toLocalTime() ).toStringZ( "dd.MM.yyyy hh:mm:ss" ) );
text.clear();
textExt.clear();
for(const QByteArray &obj: c.subjectInfoAttributes())
{
const QString &data = c.subjectInfo( obj );
if( data.isEmpty() )
continue;
text << data;
textExt << QString( "%1 = %2" ).arg( obj.constData() ).arg( data );
}
d->addItem( tr("Subject"), text.join( ", " ), textExt.join( "\n" ) );
d->addItem( tr("Public key"), c.keyName(), c.publicKeyHex() );
QStringList enhancedKeyUsage = c.enhancedKeyUsage().values();
if( !enhancedKeyUsage.isEmpty() )
d->addItem( tr("Enhanched key usage"), enhancedKeyUsage.join( ", " ), enhancedKeyUsage.join( "\n" ) );
QStringList policies = c.policies();
if( !policies.isEmpty() )
d->addItem( tr("Certificate policies"), policies.join( ", " ) );
d->addItem( tr("Authority key identifier"), c.toHex( c.authorityKeyIdentifier() ) );
d->addItem( tr("Subject key identifier"), c.toHex( c.subjectKeyIdentifier() ) );
QStringList keyUsage = c.keyUsage().values();
if( !keyUsage.isEmpty() )
d->addItem( tr("Key usage"), keyUsage.join( ", " ), keyUsage.join( "\n" ) );
d->parameters->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
}
示例2: setCertificate
void CertificateDialog::setCertificate( const QSslCertificate &cert )
{
d->cert = cert;
SslCertificate c = cert;
QString i;
QTextStream s( &i );
s << "<b>" << tr("Certificate Information") << "</b><br />";
s << "<hr>";
s << "<b>" << tr("This certificate is intended for following purpose(s):") << "</b>";
s << "<ul>";
Q_FOREACH( const QString &ext, c.enhancedKeyUsage() )
s << "<li>" << ext << "</li>";
s << "</ul>";
s << "<br /><br /><br /><br />";
//s << tr("* Refer to the certification authority's statement for details.") << "<br />";
s << "<hr>";
s << "<p style='margin-left: 30px;'>";
s << "<b>" << tr("Issued to:") << "</b> " << c.subjectInfo( QSslCertificate::CommonName );
s << "<br /><br /><br />";
s << "<b>" << tr("Issued by:") << "</b> " << c.issuerInfo( QSslCertificate::CommonName );
s << "<br /><br /><br />";
s << "<b>" << tr("Valid from") << "</b> " << c.effectiveDate().toLocalTime().toString( "dd.MM.yyyy" ) << " ";
s << "<b>" << tr("to") << "</b> "<< c.expiryDate().toLocalTime().toString( "dd.MM.yyyy" );
s << "</p>";
d->info->setHtml( i );
d->addItem( tr("Version"), "V" + c.version() );
d->addItem( tr("Serial number"), QString( "%1 (0x%2)" )
.arg( c.serialNumber().constData() )
.arg( QString::number( c.serialNumber().toInt(), 16 ) ) );
d->addItem( tr("Signature algorithm"), c.signatureAlgorithm() );
QStringList text, textExt;
Q_FOREACH( const QByteArray &subject, QList<QByteArray>() << "CN" << "OU" << "O" << "C" )
{
const QString &data = c.issuerInfo( subject );
if( data.isEmpty() )
continue;
text << data;
textExt << QString( "%1 = %2" ).arg( subject.constData() ).arg( data );
}
d->addItem( tr("Issuer"), text.join( ", " ), textExt.join( "\n" ) );
d->addItem( tr("Valid from"), c.effectiveDate().toLocalTime().toString( "dd.MM.yyyy hh:mm:ss" ) );
d->addItem( tr("Vaild to"), c.expiryDate().toLocalTime().toString( "dd.MM.yyyy hh:mm:ss" ) );
text.clear();
textExt.clear();
Q_FOREACH( const QByteArray &subject,
QList<QByteArray>() << "serialNumber" << "GN" << "SN" << "CN" << "OU" << "O" << "C" )
{
const QString &data = c.subjectInfo( subject );
if( data.isEmpty() )
continue;
text << data;
textExt << QString( "%1 = %2" ).arg( subject.constData() ).arg( data );
}
d->addItem( tr("Subject"), text.join( ", " ), textExt.join( "\n" ) );
d->addItem( tr("Public key"), QString("%1 (%2)")
.arg( c.publicKey().algorithm() == QSsl::Rsa ? "RSA" : "DSA" )
.arg( d->keyLenght( c.publicKey() ) ),
c.toHex( c.publicKey().toDer() ) );
QStringList enhancedKeyUsage = c.enhancedKeyUsage().values();
if( !enhancedKeyUsage.isEmpty() )
d->addItem( tr("Enhanched key usage"), enhancedKeyUsage.join( ", " ), enhancedKeyUsage.join( "\n" ) );
QStringList policies = c.policies();
if( !policies.isEmpty() )
d->addItem( tr("Certificate policies"), policies.join( ", " ) );
d->addItem( tr("Authority key identifier"), c.toHex( c.authorityKeyIdentifier() ) );
d->addItem( tr("Subject key identifier"), c.toHex( c.subjectKeyIdentifier() ) );
QStringList keyUsage = c.keyUsage().values();
if( !keyUsage.isEmpty() )
d->addItem( tr("Key usage"), keyUsage.join( ", " ), keyUsage.join( "\n" ) );
}
示例3: rect
//.........这里部分代码省略.........
setFont( sHead );
drawText( left, top, tr("SIGNED FILES") );
setPen( sPen );
drawLine( left, top+3, right, top+3 );
top += 30;
setFont( text );
setPen( oPen );
drawText( left, top, tr("FILE NAME") );
drawText( right-150, top, tr("FILE SIZE") );
for( int i = 0; i < doc->documentModel()->rowCount(); ++i )
{
int fileHeight = drawTextRect( QRect( left, top+5, right - left - 150, 20 ),
doc->documentModel()->index( i, 0 ).data().toString() );
drawTextRect( QRect( right-150, top+5, 150, fileHeight ),
doc->documentModel()->index( i, 2 ).data().toString() );
top += fileHeight;
newPage( 50 );
}
top += 35;
newPage( 50 );
setFont( sHead );
drawText( left, top, tr("SIGNERS") );
setPen( sPen );
drawLine( left, top+3, right, top+3 );
top += 30;
setFont( text );
setPen( oPen );
int i = 1;
Q_FOREACH( const DigiDocSignature &sig, doc->signatures() )
{
const SslCertificate cert = sig.cert();
bool tempel = cert.isTempel();
newPage( 50 );
drawText( left, top, tr("NO.") );
drawText( left+40, top, tempel ? tr( "COMPANY" ) : tr( "NAME" ) );
drawText( right-300, top, tempel ? tr("REGISTER CODE") : tr("PERSONAL CODE") );
drawText( right-170, top, tr("TIME") );
top += 5;
int nameHeight = drawTextRect( QRect( left+40, top, right - left - 340, 20 ),
cert.toString( cert.showCN() ? "CN" : "GN SN" ) );
drawTextRect( QRect( left, top, 40, nameHeight ),
QString::number( i++ ) );
drawTextRect( QRect( right-300, top, 130, nameHeight ),
cert.subjectInfo( "serialNumber" ) );
drawTextRect( QRect( right-170, top, 170, nameHeight ),
DateTime( sig.dateTime() ).toStringZ( "dd.MM.yyyy hh:mm:ss" ) );
top += 20 + nameHeight;
QString valid;
switch( sig.validate() )
{
case DigiDocSignature::Valid: valid.append( tr("SIGNATURE IS VALID") ); break;
case DigiDocSignature::Invalid: valid.append( tr("SIGNATURE IS NOT VALID") ); break;
case DigiDocSignature::Unknown: valid.append( tr("UNKNOWN") ); break;
}
if( sig.isTest() )
valid += " " + tr("(NB! TEST SIGNATURE)");
customText( tr("VALIDITY OF SIGNATURE"), valid );
customText( tr("ROLE / RESOLUTION"), sig.role() );
customText( tr("PLACE OF CONFIRMATION (CITY, STATE, ZIP, COUNTRY)"), sig.location() );
customText( tr("SERIAL NUMBER OF SIGNER CERTIFICATE"), cert.serialNumber() );
newPage( 50 );
drawText( left, top, tr("ISSUER OF CERTIFICATE") );
drawText( left+207, top, tr("HASH VALUE OF ISSUER'S PUBLIC KEY") );
top += 5;
int issuerHeight = drawTextRect( QRect( left, top, 200, 20 ),
cert.issuerInfo( QSslCertificate::CommonName ) );
drawTextRect( QRect( left+200, top, right - left - 200, issuerHeight ),
cert.toHex( cert.authorityKeyIdentifier() ) );
top += 20 + issuerHeight;
customText( tr("HASH VALUE OF VALIDITY CONFIRMATION (OCSP RESPONSE)"), cert.toHex( sig.ocspDigestValue() ) );
top += 15;
}
save();
newPage( 50 );
QTextDocument textDoc;
textDoc.setTextWidth( right - margin );
textDoc.setHtml( tr("The print out of files listed in the section <b>\"Signed Files\"</b> "
"are inseparable part of this Validity Confirmation Sheet.") );
translate( QPoint( left, top - 30) );
textDoc.drawContents( this , QRectF( 0, 0, right - margin, 40) );
top += 30;
restore();
newPage( 90 );
drawText( left+3, top, tr("NOTES") );
top += 10;
drawRect( left, top, right - margin, 80 );
end();
}
示例4: st
SignatureDialog::SignatureDialog( const DigiDocSignature &signature, QWidget *parent )
: QWidget( parent )
, s( signature )
, d( new SignatureDialogPrivate )
{
d->setupUi( this );
setAttribute( Qt::WA_DeleteOnClose );
setWindowFlags( Qt::Sheet );
const SslCertificate c = s.cert();
QString titleText = c.toString( c.showCN() ? "CN serialNumber" : "GN SN serialNumber" );
d->title->setText( titleText );
setWindowTitle( titleText );
QString msg;
QTextStream st( &msg );
switch( s.validate() )
{
case DigiDocSignature::Valid:
st << tr("Signature is valid"); break;
case DigiDocSignature::Invalid:
st << "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr>"
<< "<td>" << tr("Signature is not valid") << "</td>"
<< "<td align=\"right\"><a href=\"help\">" << tr("Help") << "</a></td>"
<< "</tr></table>"
<< "(" << (s.lastError().isEmpty() ? tr("Unknown error") : s.lastError()) << ")";
break;
case DigiDocSignature::Unknown:
st << "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr>"
<< "<td>" << tr("Signature status unknown") << "</td>"
<< "<td align=\"right\"><a href=\"help\">" << tr("Help") << "</a></td>"
<< "</tr></table>"
<< "(" << (s.lastError().isEmpty() ? tr("Unknown error") : s.lastError()) << ")";
break;
}
d->error->setText( msg );
const QStringList l = s.locations();
d->signerCity->setText( l.value( 0 ) );
d->signerState->setText( l.value( 1 ) );
d->signerZip->setText( l.value( 2 ) );
d->signerCountry->setText( l.value( 3 ) );
QStringList roles = s.roles();
d->signerRole->setText( roles.value(0) );
if( s.type() == DigiDocSignature::DDocType )
delete d->signerResolution;
else
d->signerResolution->setText( roles.value(1) );
// Certificate info
QTreeWidget *t = d->signatureView;
addItem( t, tr("Signing time"), s.dateTime().toString( "dd.MM.yyyy hh:mm:ss" ) );
addItem( t, tr("Signature type"), c.publicKey().algorithm() == QSsl::Rsa ? "RSA" : "DSA" );
addItem( t, tr("Signature format"), s.mediaType() );
addItem( t, tr("Signed file count"), QString::number( s.parent()->documentModel()->rowCount() ) );
addItem( t, tr("Certificate serialnumber"), c.serialNumber() );
addItem( t, tr("Certificate valid at"), c.effectiveDate().toLocalTime().toString( "dd.MM.yyyy" ) );
addItem( t, tr("Certificate valid until"), c.expiryDate().toLocalTime().toString( "dd.MM.yyyy" ) );
addItem( t, tr("Certificate issuer"), c.issuerInfo( QSslCertificate::CommonName ) );
t->resizeColumnToContents( 0 );
// OCSP info
if( s.type() == DigiDocSignature::DDocType ||
s.type() == DigiDocSignature::TMType )
{
SslCertificate ocsp = s.ocspCert();
addItem( d->ocspView, tr("Certificate issuer"), ocsp.issuerInfo( QSslCertificate::CommonName ) );
addItem( d->ocspView, tr("Certificate serialnumber"), ocsp.serialNumber() );
addItem( d->ocspView, tr("Time"), s.dateTime().toString( "dd.MM.yyyy hh:mm:ss" ) );
addItem( d->ocspView, tr("Hash value of validity confirmation"), ocsp.toHex( s.digestValue() ) );
d->ocspView->resizeColumnToContents( 0 );
}
else
d->tabWidget->removeTab( 2 );
}
示例5: QTime
//.........这里部分代码省略.........
setPen( oPen );
drawText( left, top, tr("FILE NAME") );
drawText( left+400, top, tr("FILE SIZE") );
for( int i = 0; i < doc->documentModel()->rowCount(); ++i )
{
drawLine( left, top+5, right, top+5 );
drawLine( left, top+5, left, top+25 );
drawLine( left+395, top+5, left+395, top+25 );
drawLine( right, top+5, right, top+25 );
top += 20;
drawText( left+5, top, doc->documentModel()->index( i, 0 ).data().toString() );
drawText( left+400, top, doc->documentModel()->index( i, 2 ).data().toString() );
drawLine( left, top+5, right, top+5 );
newPage( 50 );
}
top += 35;
newPage( 50 );
setFont( sHead );
drawText( left, top, tr("SIGNERS") );
setPen( sPen );
drawLine( left, top+3, right, top+3 );
top += 30;
setFont( text );
setPen( oPen );
int i = 1;
Q_FOREACH( const DigiDocSignature &sig, doc->signatures() )
{
newPage( 50 );
const SslCertificate cert = sig.cert();
bool tempel = cert.isTempel();
drawText( left, top, tr("NO.") );
drawLine( left+35, top+5, left+35, top+25 );
drawText( left+40, top, tempel ? tr( "COMPANY" ) : tr( "NAME" ) );
drawLine( right-305, top+5, right-305, top+25 );
drawText( right-300, top, tempel ? tr("REGISTER CODE") : tr("PERSONAL CODE") );
drawLine( right-165, top+5, right-165, top+25 );
drawText( right-160, top, tr("TIME") );
drawRect( left, top+5, right - margin, 20 );
top += 20;
drawText( left+5, top, QString::number( i ) );
drawText( left+40, top, cert.toString( cert.showCN() ? "CN" : "GN SN" ) );
drawText( right-300, top, cert.subjectInfo( "serialNumber" ) );
drawText( right-160, top, sig.dateTime().toString( "dd.MM.yyyy hh:mm:ss" ) + " " + timediff );
top += 25;
QString valid = tr("SIGNATURE") + " ";
switch( sig.validate() )
{
case DigiDocSignature::Valid: valid.append( tr("VALID") ); break;
case DigiDocSignature::Invalid: valid.append( tr("NOT VALID") ); break;
case DigiDocSignature::Unknown: valid.append( tr("UNKNOWN") ); break;
}
if( sig.isTest() )
valid += " " + tr("(NB! TEST SIGNATURE)");
customText( tr("VALIDITY OF SIGNATURE"), valid );
top += 45;
customText( tr("ROLE / RESOLUTION"), sig.role() );
top += 45;
customText( tr("PLACE OF CONFIRMATION (CITY, STATE, ZIP, COUNTRY)"), sig.location() );
top += 45;
customText( tr("SERIAL NUMBER OF SIGNER CERTIFICATE"), cert.serialNumber() );
top += 45;
customText( tr("ISSUER OF CERTIFICATE"), cert.issuerInfo( QSslCertificate::CommonName ) );
drawText( left+207, top, tr("HASH VALUE OF ISSUER'S PUBLIC KEY") );
drawLine( left+200, top+5, left+200, top+25 );
drawText( left+207, top+20, cert.toHex( cert.authorityKeyIdentifier() ) );
top += 45;
customText( tr("HASH VALUE OF VALIDITY CONFIRMATION (OCSP RESPONSE)"), cert.toHex( sig.ocspDigestValue() ) );
top += 60;
++i;
}
save();
newPage( 50 );
QTextDocument textDoc;
textDoc.setTextWidth( right - margin );
textDoc.setHtml( tr("The print out of files listed in the section <b>\"Signed Files\"</b> "
"are inseparable part of this Validity Confirmation Sheet.") );
translate( QPoint( left, top - 30) );
textDoc.drawContents( this , QRectF( 0, 0, right - margin, 40) );
top += 30;
restore();
newPage( 90 );
drawText( left+3, top, tr("NOTES") );
top += 10;
drawRect( left, top, right - margin, 80 );
end();
}