diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 9a57964978..2b2dbb7ae1 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -10773,7 +10773,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 191.2.3; + version = "191.2.3-1"; }; }; 9F8FE9472BAE50E50071E372 /* XCRemoteSwiftPackageReference "lottie-spm" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 81fa28071f..674a98fc2d 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/DuckDuckGo/BrowserServicesKit", "state" : { - "revision" : "b83ccf14b5844e8876de04bcc3074a15569f3b26", - "version" : "191.2.3" + "revision" : "3bac7c0924eeebd58b8868ef44489fac0fb7ec44", + "version" : "191.2.3-1" } }, { diff --git a/DuckDuckGo/PrivacyIconLogic.swift b/DuckDuckGo/PrivacyIconLogic.swift index 9ae915497f..727d46480e 100644 --- a/DuckDuckGo/PrivacyIconLogic.swift +++ b/DuckDuckGo/PrivacyIconLogic.swift @@ -37,8 +37,9 @@ final class PrivacyIconLogic { } else { let config = ContentBlocking.shared.privacyConfigurationManager.privacyConfig let isUserUnprotected = config.isUserUnprotected(domain: privacyInfo.url.host) - - let notFullyProtected = !privacyInfo.https || isUserUnprotected || privacyInfo.serverTrust == nil + + let isServerTrustInvalid = (privacyInfo.shouldCheckServerTrust ? privacyInfo.serverTrust == nil : false) + let notFullyProtected = !privacyInfo.https || isUserUnprotected || isServerTrustInvalid return notFullyProtected ? .shieldWithDot : .shield } diff --git a/DuckDuckGo/TabViewController.swift b/DuckDuckGo/TabViewController.swift index f413f40730..514b8931de 100644 --- a/DuckDuckGo/TabViewController.swift +++ b/DuckDuckGo/TabViewController.swift @@ -993,7 +993,7 @@ class TabViewController: UIViewController { self.privacyInfo = privacyInfo didGoBackForward = false } else { - privacyInfo = makePrivacyInfo(url: url) + privacyInfo = makePrivacyInfo(url: url, shouldCheckServerTrust: true) } } else { privacyInfo = nil @@ -1001,14 +1001,15 @@ class TabViewController: UIViewController { onPrivacyInfoChanged() } - public func makePrivacyInfo(url: URL) -> PrivacyInfo? { + public func makePrivacyInfo(url: URL, shouldCheckServerTrust: Bool = false) -> PrivacyInfo? { guard let host = url.host else { return nil } let entity = ContentBlocking.shared.trackerDataManager.trackerData.findParentEntityOrFallback(forHost: host) let privacyInfo = PrivacyInfo(url: url, parentEntity: entity, - protectionStatus: makeProtectionStatus(for: host)) + protectionStatus: makeProtectionStatus(for: host), + shouldCheckServerTrust: shouldCheckServerTrust) let isValid = certificateTrustEvaluator.evaluateCertificateTrust(trust: webView.serverTrust) if let isValid { privacyInfo.serverTrust = isValid ? webView.serverTrust : nil diff --git a/DuckDuckGoTests/PrivacyIconLogicTests.swift b/DuckDuckGoTests/PrivacyIconLogicTests.swift index ebecb5d55c..b12ef295e8 100644 --- a/DuckDuckGoTests/PrivacyIconLogicTests.swift +++ b/DuckDuckGoTests/PrivacyIconLogicTests.swift @@ -96,7 +96,7 @@ class PrivacyIconLogicTests: XCTestCase { let url = PrivacyIconLogicTests.pageURL let entity = Entity(displayName: "E", domains: [], prevalence: 100.0) let protectionStatus = ProtectionStatus(unprotectedTemporary: false, enabledFeatures: [], allowlisted: false, denylisted: false) - let privacyInfo = PrivacyInfo(url: url, parentEntity: entity, protectionStatus: protectionStatus) + let privacyInfo = PrivacyInfo(url: url, parentEntity: entity, protectionStatus: protectionStatus, shouldCheckServerTrust: true) let icon = PrivacyIconLogic.privacyIcon(for: privacyInfo) @@ -105,6 +105,19 @@ class PrivacyIconLogicTests: XCTestCase { XCTAssertEqual(icon, .shieldWithDot) } + func testPrivacyIconIsShieldWithoutDotForNoSecTrustAndShouldCheckServerTrustIsFalse() { + let url = PrivacyIconLogicTests.pageURL + let entity = Entity(displayName: "E", domains: [], prevalence: 100.0) + let protectionStatus = ProtectionStatus(unprotectedTemporary: false, enabledFeatures: [], allowlisted: false, denylisted: false) + let privacyInfo = PrivacyInfo(url: url, parentEntity: entity, protectionStatus: protectionStatus) + + let icon = PrivacyIconLogic.privacyIcon(for: privacyInfo) + + XCTAssertTrue(url.isHttps) + XCTAssertTrue(privacyInfo.https) + XCTAssertEqual(icon, .shield) + } + } final class MockSecTrust: SecurityTrust {}