小编Aut*_*cat的帖子

使用 TrustKit iOS 在 React-Native 应用程序中实现 ssl pinning

我正在尝试在react-native应用程序(RN 0.60)中实现SSL固定,并且我正在使用Trustkit。

按照https://github.com/datatheorem/TrustKit中发布的指南,这些是我所做的步骤:

1) 使用pod 'TrustKit'和安装 TrustKit podpod install

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];
Run Code Online (Sandbox Code Playgroud)

当我尝试做的时候

 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);
    })
Run Code Online (Sandbox Code Playgroud)

它进入内部 …

ios react-native react-native-ios trustkit

5
推荐指数
1
解决办法
4526
查看次数

标签 统计

ios ×1

react-native ×1

react-native-ios ×1

trustkit ×1