react-native-ssl-pinning
react-native-ssl-pinning copied to clipboard
[IOS] Crash [__NSArrayM insertObject:atIndex:]: object cannot be nil
Hello @MaxToyberman ,
For these 2 weeks on IOS app always got crash from thread [__NSArrayM insertObject:atIndex:]: object cannot be nil
Using this code was work on Android but always got crash on IOS, Could you elaborate how to solve this?
Thanks,
Code
import { fetch as sslFetch } from 'react-native-ssl-pinning';
static sslPinning(
axiosInstance,
url: string,
method: string,
body?: any,
incomingConfig?: {[key: string]: any},
): Promise<any> {
const requestBodyJSON = body && JSON.stringify(body)
const requestURL = axiosInstance.defaults.baseURL + url
const config = {
timeoutInterval: 10000,
sslPinning: {
certs: ["19_9_2021"]
},
headers: axiosInstance.defaults.headers.common,
method,
...(body && { body: requestBodyJSON }),
...(incomingConfig && incomingConfig),
}
return sslFetch(requestURL, config)
.then(response => {
console.log("[ServiceUtils] sslPinning ssFetch response ",response)
})
.catch( error => {
console.log("[ServiceUtils] sslPinning ssFetch error",error)
});
}
Setup

Error


Environment
- react-native version 0.61.5
- react-native-ssl-pinning 1.5.0
Hi @ek018 , Were you able to fix the issue, if yes, would you mind sharing the solution? Thanks
@MaxToyberman this is the same issue as #60 but there isnt any conculsive solution for the problem, is pkPinning mandatory for certificate pinning?
Make sure the certificate file use you are using is in binary format and ".cer" extension, the AFSecurity only supports binary format certificates and not plain text certificates. As both certificates could have an extension of .cer this is most likely the reason why it was failing, as it was in my case. To check if it is in binary format or not, just open the contents of the file, if it has words BEING KEY, END key then its plain text and the certificate can easily be converted to binary format using online tools or a command prompt command.
@shrynshjn Did you fix it with adding public keys?
Yes. @mkilp, the certificate should be in the proper format. The steps in documentation works fine, it just doesn't mention the format of the public certificate
Make sure it's a binary certificate with .cer extension
@shrynshjn Did you fix it with adding public keys?
adding public key pinning is not mandatory, only certificate pinning works, with the right certficate
Make sure the certificate file use you are using is in binary format and ".cer" extension, the AFSecurity only supports binary format certificates and not plain text certificates. As both certificates could have an extension of .cer this is most likely the reason why it was failing, as it was in my case. To check if it is in binary format or not, just open the contents of the file, if it has words BEING KEY, END key then its plain text and the certificate can easily be converted to binary format using online tools or a command prompt command.
You are a life saver