From d979cc6ec843c349ef0bd3441a430e897ba73632 Mon Sep 17 00:00:00 2001 From: Sabrina Tardio <44158575+SabrinaTardio@users.noreply.github.com> Date: Tue, 16 Apr 2024 20:47:26 +0200 Subject: [PATCH 1/2] fix dashboard (#2638) Task/Issue URL: https://app.asana.com/0/1199230911884351/1207086934879351/f Description: Solves two issues: the privacy dashboard shows untrusted site error even for safe sites (this was not visible in the ship review build) and the ssl error page was showing dashboard icon rather than the globe icon --- .../Utilities/CertificateTrustEvaluator.swift | 6 ++-- DuckDuckGo/Tab/Model/Tab.swift | 29 +++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/DuckDuckGo/Common/Utilities/CertificateTrustEvaluator.swift b/DuckDuckGo/Common/Utilities/CertificateTrustEvaluator.swift index 541f61c95d..63ea3638cd 100644 --- a/DuckDuckGo/Common/Utilities/CertificateTrustEvaluator.swift +++ b/DuckDuckGo/Common/Utilities/CertificateTrustEvaluator.swift @@ -19,13 +19,13 @@ import Foundation protocol CertificateTrustEvaluating { - func evaluateCertificateTrust(trust: SecTrust?) -> Bool? + func evaluateCertificateTrust(trust: SecTrust?) async -> Bool? } struct CertificateTrustEvaluator: CertificateTrustEvaluating { - func evaluateCertificateTrust(trust: SecTrust?) -> Bool? { + func evaluateCertificateTrust(trust: SecTrust?) async -> Bool? { var error: CFError? - guard let trust else { return nil } + guard let trust = trust else { return nil } let result = SecTrustEvaluateWithError(trust, &error) return result } diff --git a/DuckDuckGo/Tab/Model/Tab.swift b/DuckDuckGo/Tab/Model/Tab.swift index 39b66c9daa..4b6667c15c 100644 --- a/DuckDuckGo/Tab/Model/Tab.swift +++ b/DuckDuckGo/Tab/Model/Tab.swift @@ -1224,12 +1224,9 @@ protocol NewWindowPolicyDecisionMaker { webView.publisher(for: \.serverTrust) .sink { [weak self] serverTrust in - guard let self else { return } - self.isCertificateValid = self.certificateTrustEvaluator.evaluateCertificateTrust(trust: serverTrust) - if self.isCertificateValid == true { - self.privacyInfo?.serverTrust = serverTrust - } else { - self.privacyInfo?.serverTrust = nil + Task { [weak self] in + guard let self = self else { return } + await self.updatePrivacyInfo(with: serverTrust) } } .store(in: &webViewCancellables) @@ -1244,6 +1241,18 @@ protocol NewWindowPolicyDecisionMaker { } } + private func updatePrivacyInfo(with trust: SecTrust?) async { + let isValid = await self.certificateTrustEvaluator.evaluateCertificateTrust(trust: trust) + await MainActor.run { + self.isCertificateValid = isValid + if isValid ?? false { + self.privacyInfo?.serverTrust = trust + } else { + self.privacyInfo?.serverTrust = nil + } + } + } + private func dismissPresentedAlert() { if let userInteractionDialog { switch userInteractionDialog.dialog { @@ -1489,15 +1498,17 @@ extension Tab/*: NavigationResponder*/ { // to be moved to Tab+Navigation.swift invalidateInteractionStateData() - if !error.isFrameLoadInterrupted, !error.isNavigationCancelled, error.errorCode != NSURLErrorServerCertificateUntrusted, + if !error.isFrameLoadInterrupted, !error.isNavigationCancelled, // don‘t show an error page if the error was already handled // (by SearchNonexistentDomainNavigationResponder) or another navigation was triggered by `setContent` self.content.urlForWebView == url { self.error = error // when already displaying the error page and reload navigation fails again: don‘t navigate, just update page HTML - let shouldPerformAlternateNavigation = navigation.url != webView.url || navigation.navigationAction.targetFrame?.url != .error - loadErrorHTML(error, header: UserText.errorPageHeader, forUnreachableURL: url, alternate: shouldPerformAlternateNavigation) + if error.errorCode != NSURLErrorServerCertificateUntrusted { + let shouldPerformAlternateNavigation = navigation.url != webView.url || navigation.navigationAction.targetFrame?.url != .error + loadErrorHTML(error, header: UserText.errorPageHeader, forUnreachableURL: url, alternate: shouldPerformAlternateNavigation) + } } } From bc50da6127588e775bde89da1afabf8904428aa0 Mon Sep 17 00:00:00 2001 From: Dax the Duck Date: Wed, 17 Apr 2024 05:13:27 +0000 Subject: [PATCH 2/2] Bump version to 1.84.0 (165) --- Configuration/BuildNumber.xcconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Configuration/BuildNumber.xcconfig b/Configuration/BuildNumber.xcconfig index 79e38e6271..b71e1d4a29 100644 --- a/Configuration/BuildNumber.xcconfig +++ b/Configuration/BuildNumber.xcconfig @@ -1 +1 @@ -CURRENT_PROJECT_VERSION = 164 +CURRENT_PROJECT_VERSION = 165