@@ -60,6 +60,17 @@ constexpr int pushNotificationsReconnectInterval = 1000 * 60 * 2;
6060constexpr int usernamePrefillServerVersionMinSupportedMajor = 24 ;
6161constexpr int checksumRecalculateRequestServerVersionMinSupportedMajor = 24 ;
6262constexpr auto isSkipE2eeMetadataChecksumValidationAllowedInClientVersion = MIRALL_VERSION_MAJOR == 3 && MIRALL_VERSION_MINOR == 8 ;
63+
64+ bool isPushNotificationsWebSocketUrlAllowed (const QUrl &accountUrl, const QUrl &webSocketUrl)
65+ {
66+ const auto webSocketScheme = webSocketUrl.scheme ();
67+ if (webSocketScheme.compare (QLatin1String (" wss" ), Qt::CaseInsensitive) == 0 ) {
68+ return true ;
69+ }
70+
71+ return webSocketScheme.compare (QLatin1String (" ws" ), Qt::CaseInsensitive) == 0
72+ && accountUrl.scheme ().compare (QLatin1String (" http" ), Qt::CaseInsensitive) == 0 ;
73+ }
6374}
6475
6576namespace OCC {
@@ -344,6 +355,17 @@ void Account::trySetupPushNotifications()
344355 _pushNotificationsReconnectTimer.stop ();
345356
346357 if (_capabilities.availablePushNotifications () != PushNotificationType::None) {
358+ const auto webSocketUrl = _capabilities.pushNotificationsWebSocketUrl ();
359+ if (!isPushNotificationsWebSocketUrlAllowed (url (), webSocketUrl)) {
360+ qCWarning (lcAccount) << " Reject insecure push notifications websocket endpoint" << webSocketUrl << " for account" << url ();
361+ if (_pushNotifications) {
362+ delete _pushNotifications;
363+ _pushNotifications = nullptr ;
364+ }
365+ emit pushNotificationsDisabled (sharedFromThis ());
366+ return ;
367+ }
368+
347369 qCInfo (lcAccount) << " Try to setup push notifications" ;
348370
349371 if (!_pushNotifications) {
0 commit comments