fix vpn的配置管理逻辑
This commit is contained in:
parent
f252e537db
commit
80d5c7dfb1
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
try await manager.removeFromPreferences()
|
||||
guard let protocolConfiguration = manager.protocolConfiguration as? NETunnelProviderProtocol,
|
||||
protocolConfiguration.providerBundleIdentifier == env.tunBundleId else {
|
||||
try await manager.removeFromPreferences()
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
let managersAfterCleanup = try await NETunnelProviderManager.loadAllFromPreferences()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user