Skip to content

Commit 372933b

Browse files
committed
fix: Client side TLS with Strict-Transport-Security
Signed-off-by: rbran <[email protected]>
1 parent ac9dbd8 commit 372933b

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

src/gui/wizard/owncloudconnectionmethoddialog.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ void OwncloudConnectionMethodDialog::setUrl(const QUrl &url)
2424
ui->label->setText(tr("<html><head/><body><p>Failed to connect to the secure server address <em>%1</em>. How do you wish to proceed?</p></body></html>").arg(url.toDisplayString().toHtmlEscaped()));
2525
}
2626

27+
void OwncloudConnectionMethodDialog::setHTTPOnly(const bool retryHTTPonly)
28+
{
29+
ui->btnNoTLS->setEnabled(retryHTTPonly);
30+
}
2731

2832
void OwncloudConnectionMethodDialog::returnNoTLS()
2933
{

src/gui/wizard/owncloudconnectionmethoddialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class OwncloudConnectionMethodDialog : public QDialog
3737

3838
// The URL that was tried
3939
void setUrl(const QUrl &);
40+
void setHTTPOnly(const bool);
4041

4142
public slots:
4243
void returnNoTLS();

src/gui/wizard/owncloudsetuppage.cpp

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -349,35 +349,34 @@ void OwncloudSetupPage::setErrorString(const QString &err, bool retryHTTPonly)
349349
if (err.isEmpty()) {
350350
_ui.errorLabel->setVisible(false);
351351
} else {
352-
if (retryHTTPonly) {
353-
const auto urlString = url();
354-
auto url = QUrl::fromUserInput(urlString);
355-
if (url.scheme() == "https") {
356-
// Ask the user how to proceed when connecting to a https:// URL fails.
357-
// It is possible that the server is secured with client-side TLS certificates,
358-
// but that it has no way of informing the owncloud client that this is the case.
359-
360-
OwncloudConnectionMethodDialog dialog;
361-
dialog.setUrl(url);
362-
// FIXME: Synchronous dialogs are not so nice because of event loop recursion
363-
int retVal = dialog.exec();
364-
365-
switch (retVal) {
366-
case OwncloudConnectionMethodDialog::No_TLS: {
367-
url.setScheme("http");
368-
_ui.leUrl->setFullText(url.toString());
369-
// skip ahead to next page, since the user would expect us to retry automatically
370-
wizard()->next();
371-
} break;
372-
case OwncloudConnectionMethodDialog::Client_Side_TLS:
373-
addCertDial->show();
374-
break;
375-
case OwncloudConnectionMethodDialog::Closed:
376-
case OwncloudConnectionMethodDialog::Back:
377-
default:
378-
// No-op.
379-
break;
380-
}
352+
const auto urlString = url();
353+
auto url = QUrl::fromUserInput(urlString);
354+
if (url.scheme() == "https") {
355+
// Ask the user how to proceed when connecting to a https:// URL fails.
356+
// It is possible that the server is secured with client-side TLS certificates,
357+
// but that it has no way of informing the owncloud client that this is the case.
358+
359+
OwncloudConnectionMethodDialog dialog;
360+
dialog.setUrl(url);
361+
dialog.setHTTPOnly(retryHTTPonly);
362+
// FIXME: Synchronous dialogs are not so nice because of event loop recursion
363+
int retVal = dialog.exec();
364+
365+
switch (retVal) {
366+
case OwncloudConnectionMethodDialog::No_TLS: {
367+
url.setScheme("http");
368+
_ui.leUrl->setFullText(url.toString());
369+
// skip ahead to next page, since the user would expect us to retry automatically
370+
wizard()->next();
371+
} break;
372+
case OwncloudConnectionMethodDialog::Client_Side_TLS:
373+
addCertDial->show();
374+
break;
375+
case OwncloudConnectionMethodDialog::Closed:
376+
case OwncloudConnectionMethodDialog::Back:
377+
default:
378+
// No-op.
379+
break;
381380
}
382381
}
383382

0 commit comments

Comments
 (0)