当前位置: 首页>>代码示例>>C++>>正文


C++ QSslCertificate函数代码示例

本文整理汇总了C++中QSslCertificate函数的典型用法代码示例。如果您正苦于以下问题:C++ QSslCertificate函数的具体用法?C++ QSslCertificate怎么用?C++ QSslCertificate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QSslCertificate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QSslCertificate

QSslCertificate QPKCS11Private::readCert( CK_SLOT_ID slot )
{
	if( session )
		f->C_CloseSession( session );
	session = 0;
	err = f->C_OpenSession( slot, CKF_SERIAL_SESSION, 0, 0, &session );
	if( err != CKR_OK )
		return QSslCertificate();

	CK_OBJECT_HANDLE obj = CK_INVALID_HANDLE;
	if( !findObject( CKO_CERTIFICATE, &obj ) || obj == CK_INVALID_HANDLE )
		return QSslCertificate();

	unsigned long size = 0;
	if( !attribute( obj, CKA_VALUE, 0, size ) )
		return QSslCertificate();

	char *cert_data = new char[size];
	if( !attribute( obj, CKA_VALUE, (unsigned char*)cert_data, size ) )
	{
		delete [] cert_data;
		return QSslCertificate();
	}

	QSslCertificate cert = QSslCertificate( QByteArray( cert_data, size ), QSsl::Der );
	delete [] cert_data;
	return cert;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:28,代码来源:QPKCS11.cpp

示例2: SecIdentityCopyPreference

QSslCertificate AccessCert::cert()
{
#ifdef Q_OS_MAC
	SecIdentityRef identity = 0;
	OSStatus err = SecIdentityCopyPreference( CFSTR("ocsp.sk.ee"), 0, 0, &identity );
	if( !identity )
		return QSslCertificate();

	SecCertificateRef certref = 0;
	err = SecIdentityCopyCertificate( identity, &certref );
	CFRelease( identity );
	if( !certref )
		return QSslCertificate();

	CFDataRef certdata = SecCertificateCopyData( certref );
	CFRelease( certref );
	if( !certdata )
		return QSslCertificate();

	QSslCertificate cert(
		QByteArray( (const char*)CFDataGetBytePtr( certdata ), CFDataGetLength( certdata ) ), QSsl::Der );
	CFRelease( certdata );
	return cert;
#else
	return PKCS12Certificate::fromPath(
		Application::confValue( Application::PKCS12Cert ).toString(),
		Application::confValue( Application::PKCS12Pass ).toString() ).certificate();
#endif
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:29,代码来源:AccessCert.cpp

示例3: qsslkey_to_key

/*!
  Creates a self-signed certificate by signing the certificate with the specified
  key.
 */
QSslCertificate CertificateBuilder::signedCertificate(const QSslKey &qkey)
{
    gnutls_x509_privkey_t key = qsslkey_to_key(qkey, &d->errnumber);
    if (GNUTLS_E_SUCCESS != d->errnumber) {
        gnutls_x509_privkey_deinit(key);
        return QSslCertificate();
    };

    gnutls_privkey_t abstractKey;
    d->errnumber = gnutls_privkey_init(&abstractKey);
    if (GNUTLS_E_SUCCESS != d->errnumber) {
        gnutls_x509_privkey_deinit(key);
        return QSslCertificate();
    }

    gnutls_privkey_import_x509(abstractKey, key, GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE);

    d->errnumber = gnutls_x509_crt_privkey_sign(d->crt, d->crt, abstractKey, GNUTLS_DIG_SHA1, 0);

    gnutls_x509_privkey_deinit(key);

    if (GNUTLS_E_SUCCESS != d->errnumber)
        return QSslCertificate();

    return crt_to_qsslcert(d->crt, &d->errnumber);    
}
开发者ID:AidedPolecat6,项目名称:tomahawk,代码行数:30,代码来源:certificatebuilder.cpp

示例4: mCert

QgsPkiBundle::QgsPkiBundle( const QSslCertificate &clientCert,
                            const QSslKey &clientKey,
                            const QList<QSslCertificate> &caChain )
    : mCert( QSslCertificate() )
    , mCertKey( QSslKey() )
    , mCaChain( caChain )
{
  setClientCert( clientCert );
  setClientKey( clientKey );
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:10,代码来源:qgsauthconfig.cpp

示例5: windowTitle

void KeyAddDialog::addFile()
{
	QString file = QFileDialog::getOpenFileName( this, windowTitle(),
		QDesktopServices::storageLocation( QDesktopServices::DocumentsLocation ),
		tr("Certificates (*.pem *.cer *.crt)") );
	if( file.isEmpty() )
		return;

	QFile f( file );
	if( !f.open( QIODevice::ReadOnly ) )
	{
		QMessageBox::warning( this, windowTitle(), tr("Failed to open certifiacte") );
		return;
	}

	CKey k( QSslCertificate( &f, QSsl::Pem ) );
	if( k.cert.isNull() )
	{
		f.reset();
		k.setCert( QSslCertificate( &f, QSsl::Der ) );
	}
	if( k.cert.isNull() )
	{
		QMessageBox::warning( this, windowTitle(), tr("Failed to read certificate") );
	}
	else if( !SslCertificate( k.cert ).keyUsage().contains( SslCertificate::DataEncipherment ) )
	{
		QMessageBox::warning( this, windowTitle(), tr("This certificate is not usable for crypting") );
	}
	else
		addKeys( QList<CKey>() << k );

	f.close();
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:34,代码来源:KeyDialog.cpp

示例6: STACK_OF

Settings::KeyPair CertWizard::importCert(QByteArray data, const QString &pw) {
	X509 *x509 = NULL;
	EVP_PKEY *pkey = NULL;
	PKCS12 *pkcs = NULL;
	BIO *mem = NULL;
	STACK_OF(X509) *certs = NULL;
	Settings::KeyPair kp;
	int ret = 0;

	mem = BIO_new_mem_buf(data.data(), data.size());
	Q_UNUSED(BIO_set_close(mem, BIO_NOCLOSE));
	pkcs = d2i_PKCS12_bio(mem, NULL);
	if (pkcs) {
		ret = PKCS12_parse(pkcs, NULL, &pkey, &x509, &certs);
		if (pkcs && !pkey && !x509 && ! pw.isEmpty()) {
			if (certs) {
				if (ret)
					sk_X509_free(certs);
				certs = NULL;
			}
			ret = PKCS12_parse(pkcs, pw.toUtf8().constData(), &pkey, &x509, &certs);
		}
		if (pkey && x509 && X509_check_private_key(x509, pkey)) {
			unsigned char *dptr;
			QByteArray key, crt;

			key.resize(i2d_PrivateKey(pkey, NULL));
			dptr=reinterpret_cast<unsigned char *>(key.data());
			i2d_PrivateKey(pkey, &dptr);

			crt.resize(i2d_X509(x509, NULL));
			dptr=reinterpret_cast<unsigned char *>(crt.data());
			i2d_X509(x509, &dptr);

			QSslCertificate qscCert = QSslCertificate(crt, QSsl::Der);
			QSslKey qskKey = QSslKey(key, QSsl::Rsa, QSsl::Der);

			QList<QSslCertificate> qlCerts;
			qlCerts << qscCert;

			if (certs) {
				for (int i=0;i<sk_X509_num(certs);++i) {
					X509 *c = sk_X509_value(certs, i);

					crt.resize(i2d_X509(c, NULL));
					dptr=reinterpret_cast<unsigned char *>(crt.data());
					i2d_X509(c, &dptr);

					QSslCertificate cert = QSslCertificate(crt, QSsl::Der);
					qlCerts << cert;
				}
			}
			bool valid = ! qskKey.isNull();
			foreach(const QSslCertificate &cert, qlCerts)
				valid = valid && ! cert.isNull();
			if (valid)
				kp = Settings::KeyPair(qlCerts, qskKey);
		}
	}
开发者ID:CarlsonER,项目名称:mumble,代码行数:59,代码来源:Cert.cpp

示例7: qDebug

void QMyServer::_startServerEncryption ()
{
    if (QSslSocket::supportsSsl())
        qDebug()<< "Supporto SSL attivo....";
    else
        qDebug()<< "Supporto SSL non attivo.... Controlla l'include della libreria libssl .... ";

    QFile cert(":/files/resources/mycertcert.pem");
    if (!cert.open(QIODevice::ReadOnly | QIODevice::Text))
        return;

    QByteArray certba = cert.readAll();

    QFile keyfile(":/files/resources/mycertkey.pem");
    if (!keyfile.open(QIODevice::ReadOnly | QIODevice::Text))
        return;

    QByteArray keyba = keyfile.readAll();

    QSslKey keyKey(keyba, QSsl::Rsa);

    if (keyKey.isNull()) {
        qWarning("Key is null");
        socket->disconnectFromHost();
        return;
    }

    socket->setLocalCertificate( QSslCertificate( certba ) );
    socket->setPrivateKey(keyKey);
    socket->startServerEncryption();

}
开发者ID:MyOpenCommunity,项目名称:MyHomeSystemEmulator,代码行数:32,代码来源:qmyserver.cpp

示例8: QRegExp

void IdentityEditWidget::saveToIdentity(CertIdentity *id)
{
    QRegExp linebreaks = QRegExp("[\\r\\n]");
    id->setRealName(ui.realName->text());
    QStringList nicks;
    for (int i = 0; i < ui.nicknameList->count(); i++) {
        nicks << ui.nicknameList->item(i)->text();
    }
    id->setNicks(nicks);
    id->setAwayNick(ui.awayNick->text());
    id->setAwayNickEnabled(true);
    id->setAwayReason(ui.awayReason->text().remove(linebreaks));
    id->setAwayReasonEnabled(true);
    id->setAutoAwayEnabled(ui.autoAwayEnabled->isChecked());
    id->setAutoAwayTime(ui.autoAwayTime->value());
    id->setAutoAwayReason(ui.autoAwayReason->text().remove(linebreaks));
    id->setAutoAwayReasonEnabled(ui.autoAwayReasonEnabled->isChecked());
    id->setDetachAwayEnabled(ui.detachAwayEnabled->isChecked());
    id->setDetachAwayReason(ui.detachAwayReason->text().remove(linebreaks));
    id->setDetachAwayReasonEnabled(true);
    id->setIdent(ui.ident->text());
    id->setKickReason(ui.kickReason->text().remove(linebreaks));
    id->setPartReason(ui.partReason->text().remove(linebreaks));
    id->setQuitReason(ui.quitReason->text().remove(linebreaks));
#ifdef HAVE_SSL
    id->setSslKey(QSslKey(ui.keyTypeLabel->property("sslKey").toByteArray(), (QSsl::KeyAlgorithm)(ui.keyTypeLabel->property("sslKeyType").toInt())));
    id->setSslCert(QSslCertificate(ui.certOrgLabel->property("sslCert").toByteArray()));
#endif
}
开发者ID:AGBrown,项目名称:quassel-ABContrib,代码行数:29,代码来源:identityeditwidget.cpp

示例9: QTcpServer

SslServer::SslServer(const QString &certFile, const QString &keyFile, QObject *parent) :
	QTcpServer(parent)
{
	if(!QSslSocket::supportsSsl()) {
		logger::error() << "SSL support not available!";
		return;
	}

	QFile cert(certFile);
	if(!cert.open(QFile::ReadOnly)) {
		logger::error() << "Couldn't open certificate:" << cert.errorString();
		return;
	}

	QFile key(keyFile);
	if(!key.open(QFile::ReadOnly)) {
		logger::error() << "Couldn't open private key:" << key.errorString();
		return;
	}

	_cert = QSslCertificate(&cert);
	if(_cert.isNull())
		logger::error() << "Invalid certificate";

	_key = QSslKey(&key, QSsl::Rsa);
	if(_key.isNull())
		logger::error() << "Invalid private key";
}
开发者ID:GreenReaper,项目名称:Drawpile,代码行数:28,代码来源:sslserver.cpp

示例10: QSslCertificate

const QSslCertificate QgsAuthSslConfigWidget::sslCertificate()
{
  if ( mDisabled )
  {
    return QSslCertificate();
  }
  return mCert;
}
开发者ID:Gustry,项目名称:QGIS,代码行数:8,代码来源:qgsauthsslconfigwidget.cpp

示例11: qMakePair

const QPair<QSslCertificate, QSslKey> QgsAuthImportIdentityDialog::certBundleToImport()
{
  if ( mDisabled )
  {
    return qMakePair( QSslCertificate(), QSslKey() );
  }
  return mCertBundle;
}
开发者ID:GavrisAS,项目名称:QGIS,代码行数:8,代码来源:qgsauthimportidentitydialog.cpp

示例12: QSslCertificate

QSslCertificate WebPage::sslCertificate()
{
    if (url().scheme() == QLatin1String("https") && QzTools::isCertificateValid(m_sslCert)) {
        return m_sslCert;
    }

    return QSslCertificate();
}
开发者ID:593in,项目名称:qupzilla,代码行数:8,代码来源:webpage.cpp

示例13: while

QList<QSslCertificate> CertStore::list() const
{
	QList<QSslCertificate> list;
	PCCERT_CONTEXT c = 0;
	while( (c = CertEnumCertificatesInStore( d->s, c )) )
		list << QSslCertificate( QByteArray( (char*)c->pbCertEncoded, c->cbCertEncoded ), QSsl::Der );
	CertFreeCertificateContext( c );
	return list;
}
开发者ID:martinpaljak,项目名称:qesteidutil,代码行数:9,代码来源:CertStore.cpp

示例14: i2d_X509

QSslCertificate SafetPKCS12::fromX509( X509 * x509 )
{
    unsigned char *cert = NULL;
    int len = i2d_X509( (X509*)x509, &cert );
    QByteArray der;
    if( len >= 0 )
        der = QByteArray( (char*)cert, len );
    OPENSSL_free( cert );
    return QSslCertificate( der, QSsl::Der );
}
开发者ID:Cenditel,项目名称:pysafet,代码行数:10,代码来源:safetpkcs12.cpp

示例15: mSslHostPort

QgsAuthConfigSslServer::QgsAuthConfigSslServer()
  : mSslHostPort( QString() )
  , mSslCert( QSslCertificate() )
  , mSslIgnoredErrors( QList<QSslError::SslError>() )
{
  // TODO: figure out if Qt 5 has changed yet again, e.g. TLS-only
  mQtVersion = 480;
  // Qt 4.8 defaults to SecureProtocols, i.e. TlsV1SslV3
  // http://qt-project.org/doc/qt-4.8/qssl.html#SslProtocol-enum
  mSslProtocol = QSsl::SecureProtocols;
}
开发者ID:GeoCat,项目名称:QGIS,代码行数:11,代码来源:qgsauthconfig.cpp


注:本文中的QSslCertificate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。