I am using MaxToyberman /react-native-ssl-pinning library to enable the SSL pinning through react native for android . I am trying with public key pinning. even try with native module option but no luck. Getting below error error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

we try to generate public key from .cer certificate from below command echo | openssl s_client -servername -connect :443 2>NUL | openssl x509 -pubkey -noout | openssl pkey -pubin -outform DER | openssl dgst -sha256 -binary | openssl enc -base64

fetch( 'https://API_URL', { method: 'GET', pkPinning: true, sslPinning: { certs: [ 'sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAA=',

      ],
    },
    headers: {
      Accept: 'application/json; charset=utf-8',
      'Access-Control-Allow-Origin': '*',
      e_platform: 'mobile',
    },
  },
)
  .then(response => {
    console.log(JSON.stringify(response.bodyString, null, '\t'));
  })
  .catch(err => {
    console.log('err ' + err);
    console.log(`error: ${err}`);
  });

};

Expected Output : Response.ok true

Current Output : error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

0

There are 0 answers