summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-11-10 14:26:31 (GMT)
committerTobias Markmann <tm@ayena.de>2015-11-10 14:26:31 (GMT)
commit5c5a2d35583915653408aad0b48a9b648ae3191a (patch)
treeb160909a471f547a431e9e2c7ec0c0aa6a4f26ad
parent7598014eecec4a71305278ec0efd477eaa442de9 (diff)
downloadswift-5c5a2d35583915653408aad0b48a9b648ae3191a.zip
swift-5c5a2d35583915653408aad0b48a9b648ae3191a.tar.bz2
Fix certificate-less login in Swift
Commit 8405fa1 changed the client certificate handling inside Swiften to not fallback to certificate-less authentication if there is an error. This commit fixes Swift to only pass a certificate during login if a file is set and the user wants to authenticate using client certificates. Test-Information: Tested certificate-less login (worked). Tested certificate-based login (worked). Tested certificate-based login with deleted certificate file (correct error reported). Change-Id: I3b1393688c4802abfd7f66b7cb49ddd8c518e62b
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp62
1 files changed, 33 insertions, 29 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index 17176a9..229df7f 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -4,44 +4,46 @@
* See the COPYING file for more information.
*/
-#include "QtLoginWindow.h"
+#include <Swift/QtUI/QtLoginWindow.h>
-#include <boost/bind.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
#include <algorithm>
#include <cassert>
+#include <boost/bind.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
+
#include <QApplication>
#include <QBoxLayout>
+#include <QCloseEvent>
#include <QComboBox>
+#include <QCursor>
+#include <QDebug>
#include <QDesktopWidget>
#include <QFileDialog>
-#include <QStatusBar>
-#include <QToolButton>
+#include <QHBoxLayout>
+#include <QKeyEvent>
#include <QLabel>
#include <QMenuBar>
-#include <QHBoxLayout>
-#include <qdebug.h>
-#include <QCloseEvent>
-#include <QCursor>
#include <QMessageBox>
-#include <QKeyEvent>
-
-#include <Swift/Controllers/UIEvents/UIEventStream.h>
-#include <Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h>
-#include <Swift/Controllers/UIEvents/RequestFileTransferListUIEvent.h>
-#include <Swift/Controllers/UIEvents/RequestHighlightEditorUIEvent.h>
-#include <Swift/Controllers/Settings/SettingsProvider.h>
-#include <Swift/Controllers/SettingConstants.h>
-#include <Swift/QtUI/QtUISettingConstants.h>
+#include <QStatusBar>
+#include <QToolButton>
+
#include <Swiften/Base/Platform.h>
#include <Swiften/Base/Paths.h>
-#include <QtAboutWidget.h>
-#include <QtSwiftUtil.h>
-#include <QtMainWindow.h>
-#include <QtUtilities.h>
-#include <QtConnectionSettingsWindow.h>
+#include <Swift/Controllers/SettingConstants.h>
+#include <Swift/Controllers/Settings/SettingsProvider.h>
+#include <Swift/Controllers/UIEvents/RequestFileTransferListUIEvent.h>
+#include <Swift/Controllers/UIEvents/RequestHighlightEditorUIEvent.h>
+#include <Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h>
+#include <Swift/Controllers/UIEvents/UIEventStream.h>
+
+#include <Swift/QtUI/QtAboutWidget.h>
+#include <Swift/QtUI/QtConnectionSettingsWindow.h>
+#include <Swift/QtUI/QtMainWindow.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtUISettingConstants.h>
+#include <Swift/QtUI/QtUtilities.h>
#ifdef HAVE_SCHANNEL
#include "CAPICertificateSelector.h"
@@ -394,15 +396,17 @@ void QtLoginWindow::loginClicked() {
}
CertificateWithKey::ref certificate;
std::string certificateString = Q2PSTRING(certificateFile_);
+ if (!certificateString.empty()) {
#if defined(HAVE_SCHANNEL)
- if (isCAPIURI(certificateString)) {
- certificate = boost::make_shared<CAPICertificate>(certificateString, timerFactory_);
- } else {
- certificate = boost::make_shared<PKCS12Certificate>(certificateString, createSafeByteArray(Q2PSTRING(password_->text())));
- }
+ if (isCAPIURI(certificateString)) {
+ certificate = boost::make_shared<CAPICertificate>(certificateString, timerFactory_);
+ } else {
+ certificate = boost::make_shared<PKCS12Certificate>(certificateString, createSafeByteArray(Q2PSTRING(password_->text())));
+ }
#else
- certificate = boost::make_shared<PKCS12Certificate>(certificateString, createSafeByteArray(Q2PSTRING(password_->text())));
+ certificate = boost::make_shared<PKCS12Certificate>(certificateString, createSafeByteArray(Q2PSTRING(password_->text())));
#endif
+ }
onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), certificateString, certificate, currentOptions_, remember_->isChecked(), loginAutomatically_->isChecked());
if (settings_->getSetting(SettingConstants::FORGET_PASSWORDS)) { /* Mustn't remember logins */