react-native-ssl-pinning
react-native-ssl-pinning copied to clipboard
Certificates pinning not working on IOS
I drag mycert.cer to Xcode project, mark my target and 'Copy items if needed' and I use this code, but it does not work:
import {fetch} from 'react-native-ssl-pinning';
fetch('****.com', {
method: "GET" ,
timeoutInterval: communication_timeout, // milliseconds
body: {},
sslPinning: {
certs: ["mycert"]
},
headers: {
Accept: "application/json; charset=utf-8", "Access-Control-Allow-Origin": "*", "e_platform": "mobile",
}
})
.then(response => {
console.log(`response received ${response}`)
})
.catch(err => {
console.log(`error: ${err}`)
})
It threw error that: URL unsupport or The certificate for this server is not valid. You may be connecting to a server posing as “****.com”, which could jeopardize your security information.
Can anyone help me? Thanks in Advance
I am having the same problem. Can anyone who has found a solution share it? I am using a self-signed certificate.
For iOS, your certificate must be a valid SSL (eg. not self-signed) and it must be in binary, instead of plain text. Just use the openssl command to generate them.
openssl x509 -in my-site.pem -outform der -out my-site.cer
You can see if its binary of plain text by opening it inside VSCode.