【发布时间】:2019-09-02 10:34:31
【问题描述】:
我正在尝试在 react-native 应用程序 (RN 0.60) 中实现 SSL pinning,并且我正在使用 Trustkit。
按照https://github.com/datatheorem/TrustKit 中发布的指南,这些是我已经完成的步骤:
1) 使用 pod 'TrustKit' 和 pod install 安装 TrustKit pod
2) 添加到我的AppDelegate.m 这段代码:
#import <TrustKit/TrustKit.h>
//inside didFinishLaunchingWithOptions
NSDictionary *trustKitConfig =
@{
kTSKSwizzleNetworkDelegates: @YES,
kTSKPinnedDomains: @{
@"www.datatheorem.com" : @{
kTSKEnforcePinning:@YES,
kTSKIncludeSubdomains:@YES,
//Using wrong hashes so it fails
kTSKPublicKeyHashes : @[
@"Ca5gV6n7OVx4AxtEaIk8NI9qyKBTtKJjwqullb/v9hh=",
@"YLh1dUR9y6Kja30RrAn7JKnbQG/uEtLMkBgFF2Fuihh="
]
}}};
[TrustKit initSharedInstanceWithConfiguration:trustKitConfig];
当我尝试做的时候
RNFetchBlob.fetch('GET', "https://www.datatheorem.com", {}) //tried using standard fetch() but gives same results
.then(async(res) => {
console.log('RES => ' ,res)
})
// Something went wrong:
.catch((err) => {
console.log('ERROR =>', err);
})
它进入then 并没有给出任何错误,但会返回一个 200 状态码(使用错误的哈希)。
否则,使用Android它可以正常工作,进入catch并说:
Error: Pin verification failed
【问题讨论】:
标签: ios react-native react-native-ios trustkit