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

Hostname not verified #183

Open
hoatenhu opened this issue Mar 13, 2023 · 2 comments
Open

Hostname not verified #183

hoatenhu opened this issue Mar 13, 2023 · 2 comments

Comments

@hoatenhu
Copy link

I get this error when implement my app:
Hostname 192.168.1.5 not verified: certificate: sha256/9MLuJ6kyEEWuKVK0dSmIUTLzOGuDXDzOVyZY62Drv7A= DN: C=NL,ST=NH,L=Amsterdam,O=Adyen NV,OU=POS Support (test),CN=s1f2-000158212621330.test.terminal.adyen.com,1.2.840.113549.1.9.1=#1614706f73737570706f727440616479656e2e636f6d subjectAltNames: [s1f2-000158212621330.test.terminal.adyen.com]
I tried to using pkPinning: true and add the above certificate ('sha256/...') but it's still not work.

Does anyone have a solution for this problem?
Thank you!

@hoatenhu hoatenhu changed the title Hostname now verified Hostname not verified Mar 13, 2023
@dattachechar
Copy link

dattachechar commented Nov 14, 2023

@MaxToyberman getting same error while calling api with adyens root certificate in ssl pinning
any solution for this ?

@tillpos-tony
Copy link

Dang it! I was able to get it working in the exact use case. Adyen root certificate with SSL pinning. The missing piece is to get the OkHttpClient to trust all cert. Following this document to update the OkHttpUtils.java file. Here is the patch-package patch I used

diff --git a/node_modules/react-native-ssl-pinning/android/src/main/java/com/toyberman/Utils/OkHttpUtils.java b/node_modules/react-native-ssl-pinning/android/src/main/java/com/toyberman/Utils/OkHttpUtils.java
index ee3cc93..bfdc156 100644
--- a/node_modules/react-native-ssl-pinning/android/src/main/java/com/toyberman/Utils/OkHttpUtils.java
+++ b/node_modules/react-native-ssl-pinning/android/src/main/java/com/toyberman/Utils/OkHttpUtils.java
@@ -28,6 +28,8 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 import javax.net.ssl.X509TrustManager;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.HostnameVerifier;

 import okhttp3.CertificatePinner;
 import okhttp3.CookieJar;
@@ -38,6 +40,8 @@ import okhttp3.Request;
 import okhttp3.RequestBody;
 import okhttp3.logging.HttpLoggingInterceptor;

+
+
 /**
  * Created by Max Toyberman on 2/11/18.
  */
@@ -66,6 +70,12 @@ public class OkHttpUtils {

             OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
             clientBuilder.cookieJar(cookieJar);
+            clientBuilder.hostnameVerifier(new HostnameVerifier() {
+                @Override
+                public boolean verify(String hostname, SSLSession session) {
+                    return true;
+                }
+            });

             if (options.hasKey("pkPinning") && options.getBoolean("pkPinning")) {
                 // public key pinning

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

3 participants