简体   繁体   English

在 Android Studio 的主机上运行时需要 GRPC.network 调用的 TLS

[英]Need TLS for GRPC network calls when running on host in Android Studio

I'm trying to do.network calls over GRPC on a host machine (in a unit test in Android Studio), but the GRPC client cannot do TLS handshakes with the server:我正在尝试在主机上通过 GRPC 进行网络调用(在 Android Studio 的单元测试中),但 GRPC 客户端无法与服务器进行 TLS 握手:

Caused by: java.lang.RuntimeException: We can not do TLS handshake on this Android version, please install the Google Play Services Dynamic Security Provider to use TLS

Is there a way to install a TLS provider on the Android Studio host?有没有办法在 Android Studio 主机上安装 TLS 提供程序?

gRPC-Java is recommending the use of Play Service Dynamic Security Provider on Android. This ensures your application has an up-to-date OpenSSL library. gRPC-Java 建议在 Android 上使用Play Service Dynamic Security Provider 。这可确保您的应用程序拥有最新的 OpenSSL 库。 See more information in gRPC-Java SECURITY.md .gRPC-Java SECURITY.md中查看更多信息。

Another option is to use Conscrypt , which you will insert the Conscrypt TLS provider before creating a gRPC channel.另一种选择是使用Conscrypt ,您将在创建 gRPC 通道之前插入 Conscrypt TLS 提供程序。

import org.conscrypt.Conscrypt;
import java.security.Security;
...

Security.insertProviderAt(Conscrypt.newProvider(), 1);

Again, there are instructions in gRPC-Java SECURITY.md .同样,在gRPC-Java SECURITY.md中有说明。

Using Conscrypt may be easier for tests, as it only requires the Conscrypt dependency.使用 Conscrypt 可能更容易进行测试,因为它只需要 Conscrypt 依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM