在Thrift C#客户端,Java服务器上使用SSL

时间:2017-02-15 14:26:56

标签: java c# ssl thrift

要创建证书(pf用于C#,jks用于Java),我遵循了this指南

C#客户端:

X509Certificate cert = new X509Certificate2(certPath, "pass");
TStreamTransport socket = new TTLSSocket(host, port, cert, (o, c, chain, errors) => true, null);

var transport = new TBufferedTransport(socket);
TProtocol protocol = new TBinaryProtocol(transport);
_client = new HfmConnectorService.Client(protocol);

_client.InputProtocol.Transport.Open();

Java Server:

TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();

File keystoreFile = new File(System.getProperty("user.dir") + "\\keystore\\hfmcon.jks");
if(!keystoreFile.exists())
    throw new IOException("Keystore file missing"); 

params.setKeyStore(keystoreFile.getPath(), "pass");
TServerSocket serverTransport = TSSLTransportFactory.getServerSocket(port, 10000, InetAddress.getByName("localhost"), params);

客户在这一行超时

_client.InputProtocol.Transport.Open();

0 个答案:

没有答案