How to do SSL Pinning in react native app with Azure server?

483 Views Asked by At

I want to implement SSL Pinning in my react-native app as the PEN Test results suggest. Our API server is in Azure. When I googled for SSL Pinning, I found we need to generate the certificate with openssl commands. But I am getting error

s_client: -connect argument or target parameter malformed or ambiguous
unable to load certificate
4565851584:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: TRUSTED CERTIFICATE
unable to load Public Key
4369083840:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: PUBLIC KEY
47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=

I used the following command:

openssl s_client -servername <AZURE API SERVERNAME> -connect <AZURE API SERVERNAME>:443 | openssl x509 -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64

I am following this link

https://itnext.io/react-native-security-ssl-pinning-cde086210d58

Is there something that we need to do first in the Azure Portal. I need some help on it. If someone has already done SSL Pinning in React Native app with Azure server, kindly share some link as reference.

1

There are 1 best solutions below

0
Phong Nguyen On

Please try these 2 steps before running that OpenSSL command:

  1. ping {AZURE API SERVERNAME}
  2. telnet {AZURE API SERVERNAME} {port}

If the {AZURE API SERVERNAME} is not public domain/IP address, please make sure to add it to hosts file (on Windows) or Keychain (MacOS).

If these 2 above checks success, then your OpenSSL will able to return correct value normally.