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


C++ QSslConfiguration::setProtocol方法代码示例

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


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

示例1: certFile

QT_USE_NAMESPACE

//! [constructor]
SslEchoServer::SslEchoServer(quint16 port, QObject *parent) :
    QObject(parent),
    m_pWebSocketServer(Q_NULLPTR),
    m_clients()
{
    m_pWebSocketServer = new QWebSocketServer("SSL Echo Server", QWebSocketServer::SECURE_MODE, this);
    QSslConfiguration sslConfiguration;
    QFile certFile(QStringLiteral("./localhost.cert"));
    QFile keyFile(QStringLiteral("./localhost.key"));
    certFile.open(QIODevice::ReadOnly);
    keyFile.open(QIODevice::ReadOnly);
    QSslCertificate certificate(&certFile, QSsl::Pem);
    QSslKey sslKey(&keyFile, QSsl::Rsa, QSsl::Pem);
    certFile.close();
    keyFile.close();
    sslConfiguration.setProtocol(QSsl::AnyProtocol);
    sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyNone);
    sslConfiguration.setLocalCertificate(certificate);
    sslConfiguration.setPrivateKey(sslKey);
    sslConfiguration.setProtocol(QSsl::TlsV1SslV3);
    m_pWebSocketServer->setSslConfiguration(sslConfiguration);

    if (m_pWebSocketServer->listen(QHostAddress::Any, port))
    {
        qDebug() << "SSL Echo Server listening on port" << port;
        connect(m_pWebSocketServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
    }
}
开发者ID:honeyzhaoAliyun,项目名称:QtWebSocket,代码行数:31,代码来源:sslechoserver.cpp

示例2: file

void QMQTT::ClientPrivate::init(const QString& hostName, const quint16 port, const bool ssl,
                                const bool ignoreSelfSigned)
{
    _hostName = hostName;
    _port = port;
    if (ssl)
    {
#ifndef QT_NO_SSL
        QSslConfiguration sslConf = QSslConfiguration::defaultConfiguration();
        QList<QSslCertificate> certs = QSslCertificate::fromPath(QStringLiteral("./cert.crt"));
        if (!certs.isEmpty())
            sslConf.setLocalCertificate(certs.first());
        QFile file(QStringLiteral("./cert.key"));
        if (file.open(QIODevice::ReadOnly)) {
            sslConf.setPrivateKey(QSslKey(file.readAll(), QSsl::Rsa));
        }
        sslConf.setPeerVerifyMode(QSslSocket::VerifyNone);
#if QT_VERSION < 0x050000
        sslConf.setProtocol(QSsl::TlsV1);
#endif
        init(hostName, port, sslConf, ignoreSelfSigned);
#else
        Q_UNUSED(ignoreSelfSigned)
        qCritical() << "SSL not supported in this QT build";
#endif // QT_NO_SSL
    }
    else
    {
        init(new Network);
    }
}
开发者ID:george-hopkins,项目名称:qmqtt-qt4,代码行数:31,代码来源:qmqtt_client_p.cpp

示例3: QWebView

itsBrowser::itsBrowser( QWidget *parent ) :
    QWebView( parent ){

    //This is needed in Ubuntu under QT 5 for SSL to work
    //Still need to test in Windows7
    QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
    sslConfig.setProtocol( QSsl::SslV3 ); //Seems under ubuntu we need to specify the version
    QSslConfiguration::setDefaultConfiguration( sslConfig );

    QWebSettings *Tsettings = settings();
    Tsettings->setAttribute( QWebSettings::JavascriptEnabled , true );
    Tsettings->setAttribute( QWebSettings::PluginsEnabled , true );
    Tsettings->setAttribute( QWebSettings::AutoLoadImages , true );
    Tsettings->setAttribute( QWebSettings::JavaEnabled , true );
    Tsettings->setAttribute( QWebSettings::JavascriptCanOpenWindows , true);

    QNetworkCookieJar *myjar = new QNetworkCookieJar();

    this->page()->networkAccessManager()->setCookieJar(myjar);

    connect( page()->networkAccessManager(), SIGNAL( sslErrors( QNetworkReply*, const QList<QSslError> & ) ) ,this,SLOT( handleSslErrors( QNetworkReply*, const QList<QSslError> & ) ) );
    connect( page()->networkAccessManager(), SIGNAL( authenticationRequired( QNetworkReply*,QAuthenticator* ) ) , this,SLOT( ProvideAuthentication(QNetworkReply*,QAuthenticator* ) ) );
    connect( page()->networkAccessManager(), SIGNAL( proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *)) , this , SLOT( ProvideProxAuthentication( const QNetworkProxy&, QAuthenticator*) ) );
    connect( page()->networkAccessManager(), SIGNAL( finished ( QNetworkReply *)),this,SLOT(NetworkTaskfinished (QNetworkReply *)));

}
开发者ID:Serame,项目名称:iUpdate,代码行数:26,代码来源:itsbrowser.cpp

示例4: getFavoriteThreads

void HeadlessApplication::getFavoriteThreads() {

    // list green + yellow flags
    const QUrl url(DefineConsts::FORUM_URL + "/forum1f.php?owntopic=1");

    qDebug() << "getFavoriteThreads()";
    CookieJar *cookies = new CookieJar();
    cookies->loadFromDisk();
    QNetworkAccessManager *accessManager = new QNetworkAccessManager();
    accessManager->setCookieJar(cookies);


    QNetworkRequest request(url);
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");

    QSslConfiguration sslConfig = request.sslConfiguration();
    sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
    sslConfig.setPeerVerifyDepth(1);
    sslConfig.setProtocol(QSsl::TlsV1);
    sslConfig.setSslOption(QSsl::SslOptionDisableSessionTickets, true);

    QNetworkReply* reply = accessManager->get(request);
    bool ok = connect(reply, SIGNAL(finished()), this, SLOT(checkReplyFav()));
    Q_ASSERT(ok);
    Q_UNUSED(ok);
}
开发者ID:amonchakai,项目名称:HFR10Service,代码行数:26,代码来源:HeadlessApplication.cpp

示例5: createRequest

QNetworkReply* NetworkAccessManager::createRequest(Operation op, const QNetworkRequest& request, QIODevice *outgoingData)
{
	QNetworkRequest req(request);

	if(!QSslSocket::supportsSsl()) {
		if(req.url().scheme().toLower() == QLatin1String("https"))
			qCritical() << "Request using https scheme without SSL support";
	} else {
		QSslConfiguration sslConfig = req.sslConfiguration();
#ifdef U_NAM_DEBUG
		qDebug() << Q_FUNC_INFO << "NAM: ssl support, configuring it now.";
#endif
		sslConfig.setProtocol(QSsl::TlsV1SslV3);
		sslConfig.setPeerVerifyMode(QSslSocket::AutoVerifyPeer);

		req.setSslConfiguration(sslConfig);
	}

    if(op == QNetworkAccessManager::PostOperation) {
        QString contentType = req.header(QNetworkRequest::ContentTypeHeader).toString();
        if(contentType.isEmpty()) {
            req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
        }
    }

    return QNetworkAccessManager::createRequest(op, req, outgoingData);
}
开发者ID:unblu,项目名称:webkit-headless,代码行数:27,代码来源:networkaccessmanager.cpp

示例6: createRequest

QNetworkReply* NetworkAccessManager::createRequest(QNetworkAccessManager::Operation oparation, const QNetworkRequest &request, QIODevice * outgoingData = 0) {
  QNetworkRequest new_request(request);

  // emulate Firefox, allowing to disable certificate
  // verification using an environment variable
  if (!strcmp(getenv("IGNORECERT"), "1")) {
    QSslConfiguration config = request.sslConfiguration();
    config.setPeerVerifyMode(QSslSocket::VerifyNone);
    config.setProtocol(QSsl::TlsV1);
    QNetworkRequest new_request(request);
    new_request.setSslConfiguration(config);
  }

  QHashIterator<QString, QString> item(m_headers);
  while (item.hasNext()) {
      item.next();
      new_request.setRawHeader(item.key().toAscii(), item.value().toAscii());
  }
  QNetworkReply *reply = QNetworkAccessManager::createRequest(oparation, new_request, outgoingData);

  // not sure 100% if this is needed, but just in case
  if (!strcmp(getenv("IGNORECERT"), "1"))
    reply->ignoreSslErrors();

  return reply;
};
开发者ID:dmacvicar,项目名称:capybara-webkit,代码行数:26,代码来源:NetworkAccessManager.cpp

示例7: RefreshImage

void AcceptandPayOfferListPage::RefreshImage()
{
	QIcon ButtonIcon(m_placeholderImage);
	ui->imageButton->setIcon(ButtonIcon);
	
	if(m_imageList.size() > 0 && m_imageList.at(0) != QString(""))
	{
		QString parsedURL = m_imageList.at(0).simplified();
		m_url = QUrl(parsedURL);
		if(m_url.isValid())
		{
			QNetworkRequest request(m_url);
			request.setRawHeader("Accept", "q=0.9,image/webp,*/*;q=0.8");
			request.setRawHeader("Cache-Control", "no-cache");
			request.setRawHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36");
			QSslConfiguration conf = request.sslConfiguration();
			conf.setPeerVerifyMode(QSslSocket::VerifyNone);
			conf.setProtocol(QSsl::TlsV1_0);
			request.setSslConfiguration(conf);
			QNetworkReply *reply = m_netwManager->get(request);
			reply->ignoreSslErrors();
			connect(reply, SIGNAL(finished()), this, SLOT(netwManagerFinished()));
		}
	}
}
开发者ID:GregoryBetz,项目名称:syscoin2,代码行数:25,代码来源:acceptandpayofferlistpage.cpp

示例8: request

QNetworkReply * CustomNetworkAccessManager ::createRequest ( Operation op, const QNetworkRequest &req, QIODevice * outgoingData ){
    QSslConfiguration config = req.sslConfiguration();
    config.setPeerVerifyMode(mode);
    config.setProtocol(protocol);
    QNetworkRequest request(req);
    request.setSslConfiguration(config);
    return QNetworkAccessManager::createRequest(op, request, outgoingData);
}
开发者ID:jeyboy,项目名称:palyo2,代码行数:8,代码来源:custom_network_access_manager.cpp

示例9: getRequest

void PoolBrowser::getRequest( const QString &urlString )
{
    QUrl url ( urlString );
    QNetworkRequest req ( url );
    QSslConfiguration config = QSslConfiguration::defaultConfiguration();
    config.setProtocol(QSsl::SslV3);
    req.setSslConfiguration(config);
    req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=utf-8");
    m_nam.get(req);
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例10: ConfigureForLMAX

void SslClient::ConfigureForLMAX()
{
    // configure required session protocol
    QSslConfiguration config = ssl_->sslConfiguration();
    QSsl::SslProtocol p = config.sessionProtocol();
    if( p != proto_ )
        config.setProtocol(proto_);

    config.setPeerVerifyMode(QSslSocket::VerifyNone);
    config.setSslOption(QSsl::SslOptionDisableServerNameIndication, true);
    ssl_->setSslConfiguration(config);
}
开发者ID:agandzyuk,项目名称:huobi_grider,代码行数:12,代码来源:sslclient.cpp

示例11: Send

QNetworkReply* SubsonicService::Send(const QUrl& url) {
  QNetworkRequest request(url);
  // Don't try and check the authenticity of the SSL certificate - it'll almost
  // certainly be self-signed.
  QSslConfiguration sslconfig = QSslConfiguration::defaultConfiguration();
  sslconfig.setPeerVerifyMode(QSslSocket::VerifyNone);
  if (usesslv3_) {
    sslconfig.setProtocol(QSsl::SslV3);
  }
  request.setSslConfiguration(sslconfig);
  QNetworkReply *reply = network_->get(request);
  return reply;
}
开发者ID:BrummbQ,项目名称:Clementine,代码行数:13,代码来源:subsonicservice.cpp

示例12: createRequest

QNetworkReply* NetworkAccessManager::createRequest(Operation op,
                                                   const QNetworkRequest &req,
                                                   QIODevice *out){
    QNetworkRequest newreq(req);

    if(m_SslProtocol != QSsl::UnknownProtocol &&
       (req.url().scheme() == QStringLiteral("https") || req.url().scheme() == QStringLiteral("ftps"))){
        QSslConfiguration sslConfig = newreq.sslConfiguration();
        sslConfig.setProtocol(m_SslProtocol);
        newreq.setSslConfiguration(sslConfig);
    }

#if 0 //def PASSWORD_MANAGER
    if(out && op == QNetworkAccessManager::PostOperation){
        QByteArray referer = req.rawHeader("Referer");
        QString key = m_Id + QStringLiteral(":") + QUrl::fromEncoded(referer).host();

        if(Application::GetAuthData(key).isEmpty()){
            QByteArray data = out->readAll();
            out->reset();

            BoolCallBack callBack = [key, data](bool ok){
                if(ok) Application::RegisterAuthData(key, data);
            };
            ModelessDialog::Question(tr("An authentication has been executed."),
                                     tr("Save this password?"), callBack);
        }
    }
#endif

    QNetworkReply *rep = QNetworkAccessManager::createRequest(op, newreq, out);

    // QNetworkReply::error is overloaded.
    connect(rep,  SIGNAL(error(QNetworkReply::NetworkError)),
            this, SLOT(HandleError(QNetworkReply::NetworkError)));
    connect(rep,  &QNetworkReply::sslErrors,
            this, &NetworkAccessManager::HandleSslErrors);

    QString type = newreq.header(QNetworkRequest::ContentTypeHeader).value<QString>();
    if(type.toLower().contains(QStringLiteral("multipart/form-data;"))){
        UploadItem *item = NetworkController::Upload(rep, newreq.header(QNetworkRequest::ContentLengthHeader).value<qint64>());
        if(item){
            MainWindow *win = Application::GetCurrentWindow();
            if(win && win->GetTreeBank()->GetNotifier())
                win->GetTreeBank()->GetNotifier()->RegisterUpload(item);
        }
    }
    return rep;
}
开发者ID:rallentando,项目名称:vanilla,代码行数:49,代码来源:networkcontroller.cpp

示例13: qSslProtocolFromString

bool KIO::Integration::sslConfigFromMetaData(const KIO::MetaData& metadata, QSslConfiguration& sslconfig)
{
    bool success = false;

    if (metadata.contains(QL1S("ssl_in_use"))) {
        const QSsl::SslProtocol sslProto = qSslProtocolFromString(metadata.value(QL1S("ssl_protocol_version")));
        QList<QSslCipher> cipherList;
        cipherList << QSslCipher(metadata.value(QL1S("ssl_cipher_name")), sslProto);
        sslconfig.setCaCertificates(QSslCertificate::fromData(metadata.value(QL1S("ssl_peer_chain")).toUtf8()));
        sslconfig.setCiphers(cipherList);
        sslconfig.setProtocol(sslProto);
        success = sslconfig.isNull();
    }

    return success;
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例14: main

Q_DECL_EXPORT int main(int argc, char *argv[]) {
    QCoreApplication app(argc, argv);
    app.setOrganizationName("cuteTube Events");
    app.setApplicationName("cuteTube Events");
    app.setApplicationVersion("0.1.0");
    
    QSslConfiguration config = QSslConfiguration::defaultConfiguration();
    config.setProtocol(QSsl::TlsV1);
    QSslConfiguration::setDefaultConfiguration(config);
    
    Events events;
    events.getEvents();
    
    QObject::connect(&events, SIGNAL(finished()), &app, SLOT(quit()));
    
    return app.exec();
}
开发者ID:marxoft,项目名称:cutetubeevents,代码行数:17,代码来源:main.cpp

示例15: certFile

QT_USE_NAMESPACE

//! [constructor]
BCWebSocketServer::BCWebSocketServer(quint16 port, QObject *parent) :
    QObject(parent),
    m_pWebSocketServer(Q_NULLPTR),
    m_clients()
{
    m_pWebSocketServer = new QWebSocketServer(QStringLiteral("Bitcoin Exchange Server"),
                                              QWebSocketServer::NonSecureMode, //**** To be Changed after setting up OpenSSL
                                              this);
    QSslConfiguration sslConfiguration;
    QFile certFile(QStringLiteral("./localhost.cert"));
    QFile keyFile(QStringLiteral("./localhost.key"));
    /*if ( */
    certFile.open(stderr, QIODevice::ReadOnly | QIODevice::Text ) ; //&&
    keyFile.open(stderr, QIODevice::ReadOnly | QIODevice::Text) ; // )
    {
        QSslCertificate certificate(&certFile, QSsl::Pem);
        QSslKey sslKey(&keyFile, QSsl::Rsa, QSsl::Pem);
        certFile.close();
        keyFile.close();
        sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyNone);
        sslConfiguration.setLocalCertificate(certificate);
        sslConfiguration.setPrivateKey(sslKey);
        sslConfiguration.setProtocol(QSsl::TlsV1SslV3);
        m_pWebSocketServer->setSslConfiguration(sslConfiguration);

        if (m_pWebSocketServer->listen(QHostAddress::Any, port))
        {
            qDebug() << "Bitcoin Exchange Server listening on port" << port;
            connect(m_pWebSocketServer, &QWebSocketServer::newConnection,
                    this, &BCWebSocketServer::onNewConnection);
            connect(m_pWebSocketServer, &QWebSocketServer::sslErrors,
                    this, &BCWebSocketServer::onSslErrors);
        }

        _logged = false;
        _lang = NULL;

        this->data.rank = 0;
    }
}
开发者ID:abhipr1,项目名称:OpenTradingPlatform,代码行数:43,代码来源:BCWebSocketServer.cpp


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