-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ static const struct QCommandLineConfigEntry flags[] = | |
{ QCommandLine::Option, '\0', "proxy-type", "Specifies the proxy type, 'http' (default), 'none' (disable completely), or 'socks5'", QCommandLine::Optional }, | ||
{ QCommandLine::Option, '\0', "script-encoding", "Sets the encoding used for the starting script, default is 'utf8'", QCommandLine::Optional }, | ||
{ QCommandLine::Option, '\0', "web-security", "Enables web security, 'yes' (default) or 'no'", QCommandLine::Optional }, | ||
{ QCommandLine::Option, '\0', "ssl-protocol", "Sets the SSL protocol (supported protocols: 'SSLv3', 'SSLv2', 'TLSv1', 'TlsV1SslV3' (default))", QCommandLine::Optional }, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
detro
|
||
{ QCommandLine::Param, '\0', "script", "Script", QCommandLine::Flags(QCommandLine::Optional|QCommandLine::ParameterFence)}, | ||
{ QCommandLine::Param, '\0', "argument", "Script argument", QCommandLine::OptionalMultiple }, | ||
{ QCommandLine::Switch, 'h', "help", "Shows this message and quits", QCommandLine::Optional }, | ||
|
@@ -593,6 +594,9 @@ void Config::handleOption(const QString &option, const QVariant &value) | |
if (option == "web-security") { | ||
setWebSecurityEnabled(boolValue); | ||
} | ||
if (option == "ssl-protocol") { | ||
setSslProtocol(value.toString().toLower()); | ||
} | ||
} | ||
|
||
void Config::handleParam(const QString& param, const QVariant &value) | ||
|
@@ -610,3 +614,12 @@ void Config::handleError(const QString &error) | |
setUnknownOption(QString("Error: %1").arg(error)); | ||
} | ||
|
||
QString Config::sslProtocol() const | ||
{ | ||
return m_sslProtocol; | ||
} | ||
|
||
void Config::setSslProtocol(const QString& sslProtocolName) | ||
{ | ||
m_sslProtocol = sslProtocolName; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent, const Config *config | |
, m_ignoreSslErrors(config->ignoreSslErrors()) | ||
, m_idCounter(0) | ||
, m_networkDiskCache(0) | ||
, m_sslConfiguration(QSslConfiguration::defaultConfiguration()) | ||
{ | ||
setCookieJar(CookieJar::instance()); | ||
|
||
|
@@ -84,6 +85,17 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent, const Config *config | |
setCache(m_networkDiskCache); | ||
} | ||
|
||
if (QSslSocket::supportsSsl()) { | ||
m_sslConfiguration = QSslConfiguration::defaultConfiguration(); | ||
This comment has been minimized.
Sorry, something went wrong.
detro
|
||
if (config->sslProtocol() == "sslv3") { | ||
This comment has been minimized.
Sorry, something went wrong.
detro
|
||
m_sslConfiguration.setProtocol(QSsl::SslV3); | ||
} else if (config->sslProtocol() == "sslv2") { | ||
m_sslConfiguration.setProtocol(QSsl::SslV2); | ||
} else if (config->sslProtocol() == "tlsv1") { | ||
m_sslConfiguration.setProtocol(QSsl::TlsV1); | ||
} | ||
} | ||
|
||
connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(provideAuthentication(QNetworkReply*,QAuthenticator*))); | ||
connect(this, SIGNAL(finished(QNetworkReply*)), SLOT(handleFinished(QNetworkReply*))); | ||
} | ||
|
@@ -126,6 +138,8 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR | |
if (!QSslSocket::supportsSsl()) { | ||
if (req.url().scheme().toLower() == QLatin1String("https")) | ||
qWarning() << "Request using https scheme without SSL support"; | ||
} else { | ||
req.setSslConfiguration(m_sslConfiguration); | ||
} | ||
|
||
// Get the URL string before calling the superclass. Seems to work around | ||
|
@@ -149,9 +163,6 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR | |
|
||
// Pass duty to the superclass - Nothing special to do here (yet?) | ||
QNetworkReply *reply = QNetworkAccessManager::createRequest(op, req, outgoingData); | ||
if(m_ignoreSslErrors) { | ||
reply->ignoreSslErrors(); | ||
} | ||
|
||
QVariantList headers; | ||
foreach (QByteArray headerName, req.rawHeaderList()) { | ||
|
@@ -172,6 +183,7 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR | |
data["time"] = QDateTime::currentDateTime(); | ||
|
||
connect(reply, SIGNAL(readyRead()), this, SLOT(handleStarted())); | ||
connect(reply, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(handleSslErrors(const QList<QSslError> &))); | ||
|
||
emit resourceRequested(data); | ||
return reply; | ||
|
@@ -243,3 +255,14 @@ void NetworkAccessManager::provideAuthentication(QNetworkReply *reply, QAuthenti | |
authenticator->setUser(m_userName); | ||
authenticator->setPassword(m_password); | ||
} | ||
|
||
void NetworkAccessManager::handleSslErrors(const QList<QSslError> &errors) | ||
{ | ||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); | ||
foreach (QSslError e, errors) { | ||
qDebug()<<"Network - SSL Error:" << e; | ||
} | ||
|
||
if (m_ignoreSslErrors) | ||
reply->ignoreSslErrors(); | ||
} |
I think
'TlsV1SslV3' (default)
should just read "any".QSsl::SslProtocol
obviously does support that: http://doc.qt.digia.com/qt/qssl.html#SslProtocol-enum