Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ATS entirely #6642

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions ios/MullvadREST/ApiHandlers/SSLPinningURLSessionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import MullvadLogging
import Network
import Security

final class SSLPinningURLSessionDelegate: NSObject, URLSessionDelegate {
Expand All @@ -29,17 +30,32 @@ final class SSLPinningURLSessionDelegate: NSObject, URLSessionDelegate {
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void
) {
if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
let serverTrust = challenge.protectionSpace.serverTrust,
verifyServerTrust(serverTrust) {
completionHandler(.useCredential, URLCredential(trust: serverTrust))
} else {
completionHandler(.rejectProtectionSpace, nil)
let serverTrust = challenge.protectionSpace.serverTrust {
/// If a request is going through a local shadowsocks proxy, the host would be a localhost address,`
/// which would not appear in the list of valid host names in the root certificate.
/// The same goes for direct connections to the API, the host would be the IP address of the endpoint.
/// Certificates, cannot be signed for IP addresses, in such case, specify that the host name is `defaultAPIHostname`
var hostName = challenge.protectionSpace.host
let overridenHostnames = [
"\(IPv4Address.loopback)",
"\(IPv6Address.loopback)",
"\(REST.defaultAPIEndpoint.ip)",
]
if overridenHostnames.contains(hostName) {
hostName = sslHostname
}

if verifyServerTrust(serverTrust, for: hostName) {
completionHandler(.useCredential, URLCredential(trust: serverTrust))
return
}
}
completionHandler(.rejectProtectionSpace, nil)
}

// MARK: - Private

private func verifyServerTrust(_ serverTrust: SecTrust) -> Bool {
private func verifyServerTrust(_ serverTrust: SecTrust, for sslHostname: String) -> Bool {
var secResult: OSStatus

// Set SSL policy
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPN/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, SettingsMigrationUIHand
accountsProxy: appDelegate.accountsProxy,
outgoingConnectionService: OutgoingConnectionService(
outgoingConnectionProxy: OutgoingConnectionProxy(
urlSession: URLSession(configuration: .ephemeral),
urlSession: REST.makeURLSession(),
hostname: ApplicationConfiguration.hostName
)
),
Expand Down
33 changes: 0 additions & 33 deletions ios/MullvadVPN/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,6 @@
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>185.217.116.129</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>127.0.0.1</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>45.83.223.196</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
<key>NSPinnedDomains</key>
<dict>
<key>am.i.mullvad.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSPinnedCAIdentities</key>
<array>
<dict>
<key>SPKI-SHA256-BASE64</key>
<string>C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=</string>
</dict>
</array>
</dict>
</dict>
</dict>
<key>NSUserActivityTypes</key>
<array>
Expand Down
Loading