diff options
author | Klaas Freitag <freitag@owncloud.com> | 2014-04-01 17:57:37 +0400 |
---|---|---|
committer | Klaas Freitag <freitag@owncloud.com> | 2014-04-01 18:14:24 +0400 |
commit | d731f4718db3c134b6d2d43faddc0c95164816b4 (patch) | |
tree | 98129e531ae84dbe7775c802eb70b6ae03429eb4 /src/owncloudcmd | |
parent | 607e48a68bab65b4905a1dd97c97966c6e7648bb (diff) |
Add an simple SSL error handler for owncloudcmd.
Diffstat (limited to 'src/owncloudcmd')
-rw-r--r-- | src/owncloudcmd/owncloudcmd.cpp | 15 | ||||
-rw-r--r-- | src/owncloudcmd/simplesslerrorhandler.cpp | 45 | ||||
-rw-r--r-- | src/owncloudcmd/simplesslerrorhandler.h | 33 |
3 files changed, 88 insertions, 5 deletions
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp index 31ad39e3f..bf92a9122 100644 --- a/src/owncloudcmd/owncloudcmd.cpp +++ b/src/owncloudcmd/owncloudcmd.cpp @@ -22,13 +22,15 @@ #include <neon/ne_socket.h> -#include "syncengine.h" -#include <syncjournaldb.h> -#include "logger.h" +#include "mirall/syncengine.h" +#include "mirall/syncjournaldb.h" +#include "mirall/logger.h" #include "csync.h" #include "mirall/clientproxy.h" -#include "account.h" -#include <creds/httpcredentials.h> +#include "mirall/account.h" +#include "creds/httpcredentials.h" + +#include "simplesslerrorhandler.h" using namespace Mirall; @@ -143,8 +145,11 @@ int main(int argc, char **argv) { url.setScheme(url.scheme().replace("owncloud", "http")); QString folder = splitted.value(1); + SimpleSslErrorHandler *sslErrorHandler = new SimpleSslErrorHandler; + account.setUrl(url); account.setCredentials(new HttpCredentials(url.userName(), url.password())); + account.setSslErrorHandler(sslErrorHandler); AccountManager::instance()->setAccount(&account); diff --git a/src/owncloudcmd/simplesslerrorhandler.cpp b/src/owncloudcmd/simplesslerrorhandler.cpp new file mode 100644 index 000000000..5a6dcecfe --- /dev/null +++ b/src/owncloudcmd/simplesslerrorhandler.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) by Klaas Freitag <freitag@owncloud.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ +#include "mirall/mirallconfigfile.h" +#include "mirall/utility.h" +#include "mirall/account.h" +#include "simplesslerrorhandler.h" + +#include <QtGui> +#include <QtNetwork> +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#include <QtWidgets> +#endif + + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +namespace Utility { + // Used for QSSLCertificate::subjectInfo which returns a QStringList in Qt5, but a QString in Qt4 + QString escape(const QStringList &l) { return escape(l.join(';')); } +} +#endif + +bool SimpleSslErrorHandler::handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, Account *account) +{ + (void) account; + + if (!certs) { + qDebug() << "Certs parameter required but is NULL!"; + return false; + } + + foreach( QSslError error, errors ) { + certs->append( error.certificate() ); + } + return true; +} diff --git a/src/owncloudcmd/simplesslerrorhandler.h b/src/owncloudcmd/simplesslerrorhandler.h new file mode 100644 index 000000000..4add72d14 --- /dev/null +++ b/src/owncloudcmd/simplesslerrorhandler.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) by Klaas Freitag <freitag@owncloud.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ +#ifndef SIMPLESSLERRORHANDLER_H +#define SIMPLESSLERRORHANDLER_H + +#include <QtCore> +#include <QDialog> +#include <QSslCertificate> +#include <QList> + +#include "mirall/account.h" + +class QSslError; +class QSslCertificate; + +using namespace Mirall; + +class SimpleSslErrorHandler : public AbstractSslErrorHandler { +public: + bool handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, Account*); +}; + +#endif // SIMPLESSLERRORHANDLER_H |