fix vpn的配置管理逻辑

This commit is contained in:
anlicheng 2026-05-26 21:07:42 +08:00
parent f252e537db
commit 80d5c7dfb1
2 changed files with 9 additions and 11 deletions

View File

@ -12,10 +12,10 @@ enum SDLSuperTLSVerifier {
// Base64
static let pinnedPublicKeyHashes = [
//
"Q41r6hbMWEVyxo6heNAH4Wx/TH5NNOWlNif9bewcJ3E=",
"Q41r6hbMWEVyxo6heNAH4Wx/TH5NNOWlNif9bewcJ3E=".lowercased(),
//
"oeU0bWqLWMdn79s4ZHz6IRwXmFX4p70u/Qt9VrsDIb4="
"oeU0bWqLWMdn79s4ZHz6IRwXmFX4p70u/Qt9VrsDIb4=".lowercased()
]
static func verify(trust: sec_trust_t, host: String) -> Bool {
@ -53,13 +53,13 @@ enum SDLSuperTLSVerifier {
// --- Step 5: SHA256 ---
let hash = SHA256.hash(data: publicKeyData)
let hashBase64 = Data(hash).base64EncodedString()
let hashBase64 = Data(hash).base64EncodedString().lowercased()
if pinnedPublicKeyHashes.contains(hashBase64) {
SDLLogger.log("✅ 公钥校验通过", for: .debug)
return true
} else {
SDLLogger.log("⚠️ 公钥不匹配! 收到: \(hashBase64)", for: .debug)
SDLLogger.log("⚠️ 公钥不匹配! 收到: \(hashBase64), config hashes: \(pinnedPublicKeyHashes)", for: .debug)
return false
}
}

View File

@ -128,13 +128,11 @@ class VPNManager {
let env = SystemConfig.getCurrentEnvConfig()
for manager in managers {
// guard let protocolConfiguration = manager.protocolConfiguration as? NETunnelProviderProtocol,
// protocolConfiguration.providerBundleIdentifier == env.tunBundleId else {
// try await manager.removeFromPreferences()
// continue
// }
// TODO Debug
guard let protocolConfiguration = manager.protocolConfiguration as? NETunnelProviderProtocol,
protocolConfiguration.providerBundleIdentifier == env.tunBundleId else {
try await manager.removeFromPreferences()
continue
}
}
let managersAfterCleanup = try await NETunnelProviderManager.loadAllFromPreferences()