Ignore some SSL errors
This commit is contained in:
parent
1768b29a9e
commit
477aeeded0
2 changed files with 33 additions and 0 deletions
|
@ -8,9 +8,17 @@ IppPrinter::IppPrinter()
|
|||
_job_cancel_nam = new QNetworkAccessManager(this);
|
||||
|
||||
connect(_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(getPrinterAttributesFinished(QNetworkReply*)));
|
||||
connect(_nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList<QSslError>&)));
|
||||
|
||||
connect(_print_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(printRequestFinished(QNetworkReply*)));
|
||||
connect(_print_nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList<QSslError>&)));
|
||||
|
||||
connect(_jobs_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(getJobsRequestFinished(QNetworkReply*)));
|
||||
connect(_jobs_nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList<QSslError>&)));
|
||||
|
||||
connect(_job_cancel_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(cancelJobFinished(QNetworkReply*)));
|
||||
connect(_job_cancel_nam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList<QSslError>&)));
|
||||
|
||||
QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged);
|
||||
}
|
||||
|
||||
|
@ -161,6 +169,29 @@ void IppPrinter::cancelJobFinished(QNetworkReply *reply)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void IppPrinter::ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
|
||||
{
|
||||
QList<QSslError> IgnoredSslErrors = {QSslError::NoError,
|
||||
QSslError::SelfSignedCertificate,
|
||||
QSslError::HostNameMismatch,
|
||||
QSslError::UnableToGetLocalIssuerCertificate,
|
||||
QSslError::UnableToVerifyFirstCertificate
|
||||
};
|
||||
|
||||
qDebug() << errors;
|
||||
for (QList<QSslError>::const_iterator it = errors.constBegin(); it != errors.constEnd(); it++) {
|
||||
if(!IgnoredSslErrors.contains(it->error())) {
|
||||
qDebug() << "Bad error: " << int(it->error()) << it->error();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// For whatever reason, it doesn't work to pass IgnoredSslErrors here
|
||||
reply->ignoreSslErrors(errors);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IppPrinter::print(QJsonObject attrs, QString filename){
|
||||
qDebug() << "printing" << filename << attrs;
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public slots:
|
|||
void getJobsRequestFinished(QNetworkReply* reply);
|
||||
void cancelJobFinished(QNetworkReply* reply);
|
||||
|
||||
void ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||
|
||||
private:
|
||||
QUrl _url;
|
||||
QUrl httpUrl();
|
||||
|
|
Loading…
Reference in a new issue