我有一个使用从我创建的原始文件生成的grpc运行的python服务器。 服务器正在使用2种方式的ssl身份验证,当我从python文件运行客户端时,输入服务器自签名证书,客户端证书和客户端密钥时,它可以正确连接,但是我也试图在我的android应用程序中实现这一点,我为此尝试使用sslcontext builder,并破坏了我在“原始”目录中上述的3个项(2个证书和1个密钥),但似乎无法识别它们。
private static SslContext buildSslContext(String trustFile, String clientCertFile, String clientKeyFile) throws SSLException {
return GrpcSslContexts.forClient()
.trustManager(new File(trustFile))
.keyManager(new File(clientCertFile), new File(clientKeyFile))
.build();
}
mChannel = NettyChannelBuilder.forAddress("MyServer", 5051).negotiationType(NegotiationType.TLS).sslContext(buildSslContext("server.pem","client.pem","key.pem")).build();
,我收到此错误“原因:java.lang.IllegalArgumentException:文件不包含有效证书:server.pem”