本文整理汇总了C++中QSslConfiguration类的典型用法代码示例。如果您正苦于以下问题:C++ QSslConfiguration类的具体用法?C++ QSslConfiguration怎么用?C++ QSslConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSslConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QNetworkAccessManager
void MusicRadioPlayListThread::startToDownload(const QString &id)
{
m_manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(QUrl(playListUrl + id));
#ifndef QT_NO_SSL
connect(m_manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
M_LOGGER_INFO(QString("MusicRadioPlayListThread Support ssl: %1").arg(QSslSocket::supportsSsl()));
QSslConfiguration sslConfig = request.sslConfiguration();
sslConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
request.setSslConfiguration(sslConfig);
#endif
if(m_cookJar)
{
m_manager->setCookieJar(m_cookJar);
m_cookJar->setParent(nullptr);
}
m_reply = m_manager->get(request);
connect(m_reply, SIGNAL(finished()), SLOT(downLoadFinished()));
connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(replyError(QNetworkReply::NetworkError)));
}
示例2: locker
//-----------------------------------------------------------------------------
void
UrlFactory::_tryCorrectGoogleVersions(QNetworkAccessManager* networkManager)
{
QMutexLocker locker(&_googleVersionMutex);
if (_googleVersionRetrieved) {
return;
}
_googleVersionRetrieved = true;
if(networkManager)
{
QNetworkRequest qheader;
QNetworkProxy proxy = networkManager->proxy();
QNetworkProxy tProxy;
tProxy.setType(QNetworkProxy::DefaultProxy);
networkManager->setProxy(tProxy);
QSslConfiguration conf = qheader.sslConfiguration();
conf.setPeerVerifyMode(QSslSocket::VerifyNone);
qheader.setSslConfiguration(conf);
QString url = "http://maps.google.com/maps/api/js?v=3.2&sensor=false";
qheader.setUrl(QUrl(url));
QByteArray ua;
ua.append(getQGCMapEngine()->userAgent());
qheader.setRawHeader("User-Agent", ua);
_googleReply = networkManager->get(qheader);
connect(_googleReply, &QNetworkReply::finished, this, &UrlFactory::_googleVersionCompleted);
connect(_googleReply, &QNetworkReply::destroyed, this, &UrlFactory::_replyDestroyed);
connect(_googleReply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
this, &UrlFactory::_networkReplyError);
networkManager->setProxy(proxy);
}
}
示例3: new_request
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;
};
示例4: 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 *)));
}
示例5: QLatin1String
void QNetworkAccessHttpBackend::replyFinished()
{
if (httpReply->bytesAvailable())
// we haven't read everything yet. Wait some more.
return;
int statusCode = httpReply->statusCode();
if (statusCode >= 400) {
// it's an error reply
QString msg = QLatin1String(QT_TRANSLATE_NOOP("QNetworkReply",
"Error downloading %1 - server replied: %2"));
msg = msg.arg(url().toString(), httpReply->reasonPhrase());
error(statusCodeFromHttp(httpReply->statusCode(), httpReply->url()), msg);
}
#ifndef QT_NO_OPENSSL
// store the SSL configuration now
// once we call finished(), we won't have access to httpReply anymore
QSslConfiguration sslConfig = httpReply->sslConfiguration();
if (pendingSslConfiguration)
*pendingSslConfiguration = sslConfig;
else if (!sslConfig.isNull())
pendingSslConfiguration = new QSslConfiguration(sslConfig);
#endif
finished();
}
示例6: Q_UNUSED
bool QgsAuthIdentCertMethod::updateNetworkRequest( QNetworkRequest &request, const QString &authcfg,
const QString &dataprovider )
{
Q_UNUSED( dataprovider )
QMutexLocker locker( &mMutex );
// TODO: is this too restrictive, to intercept only HTTPS connections?
if ( request.url().scheme().toLower() != QLatin1String( "https" ) )
{
QgsDebugMsg( QStringLiteral( "Update request SSL config SKIPPED for authcfg %1: not HTTPS" ).arg( authcfg ) );
return true;
}
QgsDebugMsg( QStringLiteral( "Update request SSL config: HTTPS connection for authcfg: %1" ).arg( authcfg ) );
QgsPkiConfigBundle *pkibundle = getPkiConfigBundle( authcfg );
if ( !pkibundle || !pkibundle->isValid() )
{
QgsDebugMsg( QStringLiteral( "Update request SSL config FAILED for authcfg: %1: PKI bundle invalid" ).arg( authcfg ) );
return false;
}
QgsDebugMsg( QStringLiteral( "Update request SSL config: PKI bundle valid for authcfg: %1" ).arg( authcfg ) );
QSslConfiguration sslConfig = request.sslConfiguration();
//QSslConfiguration sslConfig( QSslConfiguration::defaultConfiguration() );
sslConfig.setLocalCertificate( pkibundle->clientCert() );
sslConfig.setPrivateKey( pkibundle->clientCertKey() );
request.setSslConfiguration( sslConfig );
return true;
}
示例7: 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);
}
}
示例8: QObject
QT_USE_NAMESPACE
//! [constructor]
SslEchoServer::SslEchoServer(quint16 port, QObject *parent) :
QObject(parent),
m_pWebSocketServer(Q_NULLPTR),
m_clients()
{
m_pWebSocketServer = new QWebSocketServer(QStringLiteral("SSL Echo Server"),
QWebSocketServer::SecureMode,
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.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, &QWebSocketServer::newConnection,
this, &SslEchoServer::onNewConnection);
connect(m_pWebSocketServer, &QWebSocketServer::sslErrors,
this, &SslEchoServer::onSslErrors);
}
}
示例9: ButtonIcon
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()));
}
}
}
示例10: req
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);
}
示例11: setProxy
void NetworkAccessManager::loadSettings()
{
QSettings settings;
settings.beginGroup(QLatin1String("proxy"));
QNetworkProxy proxy;
if (settings.value(QLatin1String("enabled"), false).toBool()) {
if (settings.value(QLatin1String("type"), 0).toInt() == 0)
proxy.setType(QNetworkProxy::Socks5Proxy);
else
proxy.setType(QNetworkProxy::HttpProxy);
proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
proxy.setUser(settings.value(QLatin1String("userName")).toString());
proxy.setPassword(settings.value(QLatin1String("password")).toString());
}
setProxy(proxy);
settings.endGroup();
#ifndef QT_NO_OPENSSL
QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
QList<QSslCertificate> ca_list = sslCfg.caCertificates();
QList<QSslCertificate> ca_new = QSslCertificate::fromData(settings.value(QLatin1String("CaCertificates")).toByteArray());
ca_list += ca_new;
sslCfg.setCaCertificates(ca_list);
QSslConfiguration::setDefaultConfiguration(sslCfg);
#endif
}
示例12: url
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);
}
示例13: IODeviceSocket
SslTlsSocket::SslTlsSocket(QSslSocket *sock, const QString &host, const quint16 port, const bool startEncrypted):
IODeviceSocket(sock), startEncrypted(startEncrypted), host(host), port(port), m_proxySettings(ProxySettings::RespectSystemProxy)
{
// The Qt API for deciding about whereabouts of a SSL connection is unfortunately blocking, ie. one is expected to
// call a function from a slot attached to the sslErrors signal to tell the code whether to proceed or not.
// In QML, one cannot display a dialog box with a nested event loop, so this means that we have to deal with SSL/TLS
// establishing at higher level.
sock->ignoreSslErrors();
sock->setProtocol(QSsl::AnyProtocol);
sock->setPeerVerifyMode(QSslSocket::QueryPeer);
// In response to the attacks related to the SSL compression, Digia has decided to disable SSL compression starting in
// Qt 4.8.4 -- see http://qt.digia.com/en/Release-Notes/security-issue-september-2012/.
// I have brought this up on the imap-protocol mailing list; the consensus seemed to be that the likelihood of an
// successful exploit on an IMAP conversation is very unlikely. The compression itself is, on the other hand, a
// very worthwhile goal, so we explicitly enable it again.
// Unfortunately, this was backported to older Qt versions as well (see qt4.git's 3488f1db96dbf70bb0486d3013d86252ebf433e0),
// but there is no way of enabling compression back again.
QSslConfiguration sslConf = sock->sslConfiguration();
sslConf.setSslOption(QSsl::SslOptionDisableCompression, false);
sock->setSslConfiguration(sslConf);
connect(sock, &QSslSocket::encrypted, this, &Socket::encrypted);
connect(sock, &QAbstractSocket::stateChanged, this, &SslTlsSocket::handleStateChanged);
connect(sock, static_cast<void (QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QAbstractSocket::error),
this, &SslTlsSocket::handleSocketError);
}
示例14: 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);
}
示例15: nam
BluecherryApp::BluecherryApp()
: nam(new QNetworkAccessManager(this)), liveView(new LiveViewManager(this)),
globalRate(new TransferRateCalculator(this)), m_updateChecker(0),
m_livePaused(false), m_inPauseQuery(false),
m_screensaverInhibited(false), m_screensaveValue(0)
{
Q_ASSERT(!bcApp);
bcApp = this;
m_serverRepository = new DVRServerRepository(this);
connect(qApp, SIGNAL(aboutToQuit()), SLOT(aboutToQuit()));
appIcon.addFile(QLatin1String(":/icons/icon16.png"));
appIcon.addFile(QLatin1String(":/icons/icon32.png"));
appIcon.addFile(QLatin1String(":/icons/icon64.png"));
appIcon.addFile(QLatin1String(":/icons/bluecherry-client.png"));
qApp->setWindowIcon(appIcon);
connect(nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
/* Don't use the system CAs to verify certificates */
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
sslConfig.setCaCertificates(QList<QSslCertificate>());
#if QT_VERSION >= 0x040800
/* SNI breaks connections (before sslError, even) when the hostname does
* not match the server. */
sslConfig.setSslOption(QSsl::SslOptionDisableServerNameIndication, true);
#endif
QSslConfiguration::setDefaultConfiguration(sslConfig);
loadServers();
if (shouldAddLocalServer())
addLocalServer();
autoConnectServers();
sendSettingsChanged();
m_updateChecker = new UpdateChecker(nam, this);
connect(m_updateChecker, SIGNAL(newVersionAvailable(Version)), this, SLOT(newVersionAvailable(Version)));
QSettings settings;
if (!settings.value(QLatin1String("ui/disableUpdateNotifications"), false).toBool())
{
startUpdateChecker();
}
m_mediaDownloadManager = new MediaDownloadManager(this);
m_mediaDownloadManager->setCookieJar(nam->cookieJar());
m_eventDownloadManager = new EventDownloadManager(this);
connect(m_serverRepository, SIGNAL(serverRemoved(DVRServer*)), m_eventDownloadManager, SLOT(serverRemoved(DVRServer*)));
registerVideoPlayerFactory();
connect(qApp, SIGNAL(commitDataRequest(QSessionManager&)), this, SLOT(commitDataRequest(QSessionManager&)));
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveSettings()));
}