React Native SSL Pinning multiple .cer

1k Views Asked by At

I was going through the app package from

https://www.npmjs.com/package/react-native-ssl-pinning

For both of the app, the method are : Public Key Pinning

For Android, I've no issue to create two public key for two different domain I've to handshake.

This is my question,

For IOS react-native, can i include two .cer for public key pinning?

Based on their documentation for IOS:

(skip this if you are using certificate pinning) no extra step needed for public key pinning, AFNetworking will extract the public key from the certificate.

So there is no extra step needed for public key, for IOS the AFNetworking will extract the public key from the certificate , .cer.

If I require to implement two .cer?

1

There are 1 best solutions below

0
Dror Bar On

Take a look at this guide (IOS part in your case). You can easily and quickly set up multiple public key pinnings, the relevant code in AppDelegate.m would look like this:

kTSKPinnedDomains: @{
        @"busdue.com" : @{
            kTSKIncludeSubdomains: @YES, // Pin all subdomains
            kTSKEnforcePinning: @YES, // Block connections if pinning validation failed
            kTSKDisableDefaultReportUri: @YES,
            kTSKPublicKeyHashes : @[
              @"dz0GbS1i4LnBsJwhRw3iuZmVcgqpn+AlxSBRxUbOz0k=",
              @"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=", // Fake backup key but we need to provide 2 pins
            ],
        },
        @"another.domain.com" : @{
            kTSKIncludeSubdomains: @YES, // Pin all subdomains
            kTSKEnforcePinning: @YES, // Block connections if pinning validation failed
            kTSKDisableDefaultReportUri: @YES,
            kTSKPublicKeyHashes : @[
              @"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA =",
              @"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=", // Fake backup key but we need to provide 2 pins
            ],
        },
    }};