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


C++ QSslCertificate::isNull方法代码示例

本文整理汇总了C++中QSslCertificate::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QSslCertificate::isNull方法的具体用法?C++ QSslCertificate::isNull怎么用?C++ QSslCertificate::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSslCertificate的用法示例。


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

示例1: updateCert

void SettingsDialog::updateCert()
{
	QSslCertificate c = AccessCert::cert();
	if( !c.isNull() )
		d->p12Error->setText( tr("Issued to: %1\nValid to: %2").arg( c.subjectInfo( QSslCertificate::CommonName ), c.expiryDate().toString("dd.MM.yyyy") ) );
	else
		d->p12Error->setText( tr("Server access certificate is not installed."));
	d->showP12Cert->setEnabled( !c.isNull() );
	d->showP12Cert->setProperty( "cert", QVariant::fromValue( c ) );
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:10,代码来源:SettingsDialog.cpp

示例2: updateCert

void SettingsDialog::updateCert()
{
	QSslCertificate c = AccessCert::cert();
	if( !c.isNull() )
		d->p12Error->setText( tr("Issued to: %1<br />Valid to: %2 %3")
			.arg( SslCertificate(c).subjectInfo( QSslCertificate::CommonName ) )
			.arg( c.expiryDate().toString("dd.MM.yyyy") )
			.arg( !c.isValid() ? "<font color='red'>(" + tr("expired") + ")</font>" : "" ) );
	else
		d->p12Error->setText( "<b>" + tr("Server access certificate is not installed.") + "</b>" );
	d->showP12Cert->setEnabled( !c.isNull() );
	d->showP12Cert->setProperty( "cert", QVariant::fromValue( c ) );
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:13,代码来源:SettingsDialog.cpp

示例3:

QList<QSslCertificate> Connection::peerCertificateChain() const {
	const QSslCertificate cert = qtsSocket->peerCertificate();
	if (cert.isNull())
		return QList<QSslCertificate>();
	else
		return qtsSocket->peerCertificateChain() << cert;
}
开发者ID:Acidburn0zzz,项目名称:mumble,代码行数:7,代码来源:Connection.cpp

示例4: isKeyForCert

bool Server::isKeyForCert(const QSslKey &key, const QSslCertificate &cert) {
	if (key.isNull() || cert.isNull() || (key.type() != QSsl::PrivateKey))
		return false;

	QByteArray qbaKey = key.toDer();
	QByteArray qbaCert = cert.toDer();

	X509 *x509 = NULL;
	EVP_PKEY *pkey = NULL;
	BIO *mem = NULL;

	mem = BIO_new_mem_buf(qbaKey.data(), qbaKey.size());
	Q_UNUSED(BIO_set_close(mem, BIO_NOCLOSE));
	pkey = d2i_PrivateKey_bio(mem, NULL);
	BIO_free(mem);

	mem = BIO_new_mem_buf(qbaCert.data(), qbaCert.size());
	Q_UNUSED(BIO_set_close(mem, BIO_NOCLOSE));
	x509 = d2i_X509_bio(mem, NULL);
	BIO_free(mem);
	mem = NULL;

	if (x509 && pkey && X509_check_private_key(x509, pkey)) {
		EVP_PKEY_free(pkey);
		X509_free(x509);
		return true;
	}

	if (pkey)
		EVP_PKEY_free(pkey);
	if (x509)
		X509_free(x509);
	return false;
}
开发者ID:davidebeatrici,项目名称:mumble,代码行数:34,代码来源:Cert.cpp

示例5: checkSslFingerPrint

bool FvUpdater::checkSslFingerPrint(QUrl urltoCheck)
{
	if(urltoCheck.scheme()!="https")
	{
		qWarning()<<tr("SSL fingerprint check: The url %1 is not a ssl connection!").arg(urltoCheck.toString());
		return false;
	}

	QSslSocket *socket = new QSslSocket(this);
	socket->connectToHostEncrypted(urltoCheck.host(), 443);
	if( !socket->waitForEncrypted(1000))	// waits until ssl emits encrypted(), max 1000msecs
	{
		qWarning()<<"SSL fingerprint check: Unable to connect SSL server: "<<socket->sslErrors();
		return false;
	}

	QSslCertificate cert = socket->peerCertificate();

	if(cert.isNull())
	{
		qWarning()<<"SSL fingerprint check: Unable to retrieve SSL server certificate.";
		return false;
	}

	// COmpare digests
	if(cert.digest().toHex() != m_requiredSslFingerprint)
	{
		qWarning()<<"SSL fingerprint check: FINGERPRINT MISMATCH! Server digest="<<cert.digest().toHex()<<", requiered ssl digest="<<m_requiredSslFingerprint;
		return false;
	}
	
	return true;
}
开发者ID:macressler,项目名称:hifi,代码行数:33,代码来源:fvupdater.cpp

示例6: setClientCert

void QgsPkiBundle::setClientCert( const QSslCertificate &cert )
{
  mCert.clear();
  if ( !cert.isNull() )
  {
    mCert = cert;
  }
}
开发者ID:GeoCat,项目名称:QGIS,代码行数:8,代码来源:qgsauthconfig.cpp

示例7: 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;
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:58,代码来源:InstallChecker_mac.cpp

示例8: 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);
            }
        }
    }
}
开发者ID:dkonigsberg,项目名称:LogicPaste,代码行数:57,代码来源:Pastebin.cpp

示例9: setToken

void SSLConnect::setToken( const QSslCertificate &cert, Qt::HANDLE key )
{
	if( !d->ssl )
		return d->setError( tr("SSL context is missing") );
	if( cert.isNull() )
		return d->setError( tr("Certificate is empty") );
	if( !SSL_use_certificate( d->ssl, X509_dup( (X509*)cert.handle() ) ) ||
		!SSL_use_PrivateKey( d->ssl, (EVP_PKEY*)key ) )
		d->setError();
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:10,代码来源:sslConnect.cpp

示例10: onSslErrors

void SeafileApiClient::onSslErrors(const QList<QSslError>& errors)
{
    QUrl url = reply_->url();
    QSslCertificate cert = reply_->sslConfiguration().peerCertificate();
    if (cert.isNull()) {
        // The server has no ssl certificate, we do nothing and let the
        // request fail
        qDebug("the certificate for %s is null", url.toString().toUtf8().data());
        return;
    }

    CertsManager *mgr = seafApplet->certsManager();

    QSslCertificate saved_cert = mgr->getCertificate(url.toString());
    if (saved_cert.isNull()) {
        // This is the first time when the client connects to the server.
        QString question = tr("<b>Warning:</b> The ssl certificate of this server is not trusted, proceed anyway?");
        if (seafApplet->yesOrNoBox(question)) {
            mgr->saveCertificate(url, cert);
            reply_->ignoreSslErrors();
        }

        return;
    } else if (saved_cert == cert) {
        // The user has choosen to trust the certificate before
        reply_->ignoreSslErrors();
        return;
    } else {
        /**
         * The cert which the user had chosen to trust has been changed. It
         * may be either:
         *
         * 1. The server has changed its ssl certificate
         * 2. The user's connection is under security attack
         *
         * Anyway, we'll prompt the user
         */

        SslConfirmDialog dialog(url, seafApplet->mainWindow());
        if (dialog.exec() == QDialog::Accepted) {
            reply_->ignoreSslErrors();
            if (dialog.rememberChoice()) {
                mgr->saveCertificate(url, cert);
            }
        } else {
            reply_->abort();
        }
        return;
    }

    // SslConfirmDialog *dialog = new SslConfirmDialog(url, cert, errors, seafApplet->mainWindow());
    // dialog->show();
    // dialog->raise();
    // dialog->activateWindow();
}
开发者ID:unityweb,项目名称:seafile-client-1,代码行数:55,代码来源:api-client.cpp

示例11: sslErrors

void BrowserWidget::sslErrors(QNetworkReply *reply, const QList<QSslError> &sslErrors) {
    QSslCertificate sslCert;
    if (sslErrors.count() == 1) {
        sslCert = sslErrors[0].certificate();
        if (! sslCert.isNull() && acceptedSslCerts.contains(sslCert)) {
            reply->ignoreSslErrors();
            return;
        }
    }
    QString msg = "<qt>There is a problem with the site's certificate:<ul>";
    for (int i = 0; i < sslErrors.count(); i++) {
        msg += "<li>" + sslErrors[i].errorString() + "</li>";
    }
    msg += "</ul>Do you want to ignore these errors?</qt>";
    if (QMessageBox::warning(this, "SSL Errors", msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
        if (! sslCert.isNull() && ! acceptedSslCerts.contains(sslCert)) {
            acceptedSslCerts.append(QSslCertificate(sslCert));
        }
        reply->ignoreSslErrors();
    }
}
开发者ID:gabrys,项目名称:ffbrowser,代码行数:21,代码来源:browserwidget.cpp

示例12: onSslErrors

void FileServerTask::onSslErrors(const QList<QSslError>& errors)
{
    if (canceled_) {
        return;
    }
    QUrl url = reply_->url();
    QSslCertificate cert = reply_->sslConfiguration().peerCertificate();
    CertsManager *mgr = seafApplet->certsManager();
    if (!cert.isNull() && cert == mgr->getCertificate(url.toString())) {
        reply_->ignoreSslErrors();
        return;
    }
}
开发者ID:XilongPei,项目名称:seafile-client,代码行数:13,代码来源:tasks.cpp

示例13: QWidget

QgsAuthSslConfigWidget::QgsAuthSslConfigWidget( QWidget *parent,
    const QSslCertificate& cert,
    const QString &hostport,
    const QList<QSslCertificate> &connectionCAs )
    : QWidget( parent )
    , mCert( nullptr )
    , mConnectionCAs( connectionCAs )
    , mProtocolItem( nullptr )
    , mProtocolCmbBx( nullptr )
    , mIgnoreErrorsItem( nullptr )
    , mVerifyModeItem( nullptr )
    , mVerifyPeerCmbBx( nullptr )
    , mVerifyDepthItem( nullptr )
    , mVerifyDepthSpnBx( nullptr )
    , mCanSave( false )
    , mDisabled( false )
    , mAuthNotifyLayout( nullptr )
    , mAuthNotify( nullptr )
{
  if ( QgsAuthManager::instance()->isDisabled() )
  {
    mDisabled = true;
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );

    connect( grpbxSslConfig, SIGNAL( toggled( bool ) ), this, SIGNAL( configEnabledChanged( bool ) ) );
    connect( this, SIGNAL( configEnabledChanged( bool ) ), this, SLOT( readyToSave() ) );
    connect( this, SIGNAL( hostPortValidityChanged( bool ) ), this, SLOT( readyToSave() ) );

    setUpSslConfigTree();

    lblLoadedConfig->setVisible( false );
    lblLoadedConfig->setText( QLatin1String( "" ) );

    connect( leHost, SIGNAL( textChanged( QString ) ),
             this, SLOT( validateHostPortText( QString ) ) );

    if ( !cert.isNull() )
    {
      setSslCertificate( cert, hostport );
    }
  }
}
开发者ID:Gustry,项目名称:QGIS,代码行数:49,代码来源:qgsauthsslconfigwidget.cpp

示例14: certByFilename

QSslCertificate IdentityEditWidget::certByFilename(const QString &filename)
{
    QSslCertificate cert;
    QFile certFile(filename);
    certFile.open(QIODevice::ReadOnly);
    QByteArray certRaw = certFile.read(2 << 20);
    certFile.close();

    for (int i = 0; i < 2; i++) {
        cert = QSslCertificate(certRaw, (QSsl::EncodingFormat)i);
        if (!cert.isNull())
            break;
    }
    return cert;
}
开发者ID:AGBrown,项目名称:quassel-ABContrib,代码行数:15,代码来源:identityeditwidget.cpp

示例15: socketReady

void SslCertificateMonitor::socketReady(QObject *sockobj)
{
    QSslSocket *sock = qobject_cast<QSslSocket *>(sockobj);
    if (!sock)
        return;

    QString peerName = sock->peerName();
    QSslCertificate certificate = sock->peerCertificate();

    if (*(d->acceptedCache.object(peerName)) == certificate)
        return; // Fast path for most recently accepted certificates

    // Have we been here before?
    QSslCertificate previousCertificate = cachedCertificate(peerName);

    if (!previousCertificate.isNull()) {
        if (certificate == previousCertificate) {
            // We need to add the certificate to the cache here as well as when we add to
            // the on-disk cache so that we don't hit the disk again for this site.
            d->acceptedCache.insert(peerName,new QSslCertificate(certificate));
            return; // All is well
        }

        // Cert has changed
        QString message = evaluateCertificateChange( peerName, previousCertificate,
                                                     certificate, sock->sslErrors().isEmpty() );

        d->acceptCurrent = false;
        emit certificateWarning(sock, message);
    }
    else {
        // The certificate is new. We don't show anything to user because then
        // we're simply training them to click through our warning message without
        // thinking.
        d->acceptCurrent = true;
    }

    // If the user has chosen to accept the certificate or the certficate is new
    // then we store the updated entry.
    if (d->acceptCurrent) {
        d->acceptedCache.insert(peerName,new QSslCertificate(certificate));
        addCertificate(peerName, certificate);
    }
    else {
        // Certficate has been considered dangerous by the user
        sock->abort();
    }
}
开发者ID:7174,项目名称:qt-examples,代码行数:48,代码来源:sslcertificatemonitor.cpp


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