如何在Android Java中实现两种方式的SSL握手

时间:2019-10-31 10:14:26

标签: ssl grpc grpc-java grpc-python

我正在尝试通过android java上的grpc连接到python服务器。 我已将服务器证书添加到我的android客户端中,因此我的客户端能够向我的python服务器发送grpc请求(在实现服务器端的ssl错误之前,客户端不会像以前那样发送某种ssl错误ca),但我的python服务器返回 “握手失败,并出现致命错误ssl_error_ssl”。 我认为问题在于“我在python服务器中使用双向ssl身份验证,而在我的android java客户端中,im只验证服务器确实是正确的服务器,而不发送客户端的ca。 我的问题是,如何将客户端ca发送到服务器?

我尝试搜索stackoverflow,尝试将客户端ca添加到注册服务器的ca中。 我正在使用this库来帮助我。

SSLContext sslContext = SslUtils.getSslContextForCertificateFile(this, "server.crt");
private ManagedChannel mChannel = OkHttpChannelBuilder.forAddress("MyPC", 5051).sslSocketFactory(sslContext.getSocketFactory()).build();
blockingStub = io.grpc.test.newBlockingStub(mChannel);
io.grpc.test.func req= io.grpc.test.func.newBuilder().settest("HelloWorld!").build();
io.grpc.test.func res = blockingStub.function(req);

server.crt是我的资产文件夹中的服务器证书。

我需要以某种方式在客户端中实现两种 SSL握手方式。

0 个答案:

没有答案