本文整理汇总了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()));
}
}
示例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);
}
}
示例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 *)));
}
示例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);
}
示例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);
}
示例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;
};
示例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()));
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}