react-native-ssl-pinning: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “...” which could put your confidential information at risk.

I am trying to do this but get error (IOS 14.2):

The certificate for this server is invalid. You might be connecting to a server that is pretending to be “https://…” which could put your confidential information at risk.

I copied the .cer certificate into xcode and do this:

const response = await fetch(url, {
        method: 'POST',
        body: body,
        pkPinning: true,
        disableAllSecurity: false,
        // your certificates array (needed only in android) ios will pick it automatically
        sslPinning: {
          certs: ['my_cer_file_without_extension'], // your certificates name (without extension)
        },
        headers: {
          Accept: 'application/json; charset=utf-8',
          'Access-Control-Allow-Origin': '*',
          e_platform: 'mobile',
        },
      });

Am I doing something wrong or is it no longer working? Any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

The certificate generated by using the key chain of Mac can solve this problem

in iOS, make sure that you add the certificate to the bundle resources. Go to Build Phases > Copy bundle resources > Add the certificate.

@in-html If you resolved this issue, can you share the solution? Working well on android, but not on iOS.