使用自签名SSL证书针对本地RestAPI在android上反应本地获取

问题描述

是否有一种方法可以忽略自签名的ssl,因为react native在引擎盖下的android上使用okHTTP3,并且不允许从自签名的SSL API中获取,在我的情况下,它始终是本地RestAPI,它将在本地网络上运行。解决方法是什么?

解决方法

您可以在开发版本中指定特定主机不安全

请参见https://stackoverflow.com/a/61884408/1542667

https://square.github.io/okhttp/4.x/okhttp-tls/okhttp3.tls/-handshake-certificates/-builder/add-insecure-host/