Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOS] Crash [__NSArrayM insertObject:atIndex:]: object cannot be nil #96

Open
ek018 opened this issue Sep 22, 2020 · 8 comments
Open

[IOS] Crash [__NSArrayM insertObject:atIndex:]: object cannot be nil #96

ek018 opened this issue Sep 22, 2020 · 8 comments

Comments

@ek018
Copy link

ek018 commented Sep 22, 2020

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

Screen Shot 2020-09-22 at 16 51 15

Error

Screen Shot 2020-09-22 at 16 51 33

Screen Shot 2020-09-22 at 17 21 02

Environment

  • react-native version 0.61.5
  • react-native-ssl-pinning 1.5.0
@shrynshjn
Copy link

Hi @ek018 ,
Were you able to fix the issue,
if yes, would you mind sharing the solution?
Thanks

@shrynshjn
Copy link

@MaxToyberman this is the same issue as #60 but there isnt any conculsive solution for the problem,
is pkPinning mandatory for certificate pinning?

@shrynshjn
Copy link

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.

@mkilp
Copy link

mkilp commented Aug 23, 2021

@shrynshjn Did you fix it with adding public keys?

@shrynshjn
Copy link

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

@shrynshjn
Copy link

Make sure it's a binary certificate with .cer extension

@shrynshjn
Copy link

@shrynshjn Did you fix it with adding public keys?

adding public key pinning is not mandatory, only certificate pinning works, with the right certficate

@mgroupservice
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants