FoundationURLPubKeyExtractor
在 iOS/macOS 上从域名中提取公钥的简单方法
用法
PubKeyExtractor.getPubKey(url: url, completion: {
switch $0 {
case .success(let key):
print("pubKey: \(key.base64)")
case .failure(let error):
print("Could not get key because \(error)")
}
})
注意
结果将与 .pem 不同,因为 .pem 包含一些头部。
动机
评估公钥固定技术的影响
待办:macOS 兼容(应该需要几分钟...)
Cocoapods
pod 'URLPubKeyExtractor'