Apache Ignite C#.Net thin client实现SSL验证的步骤如下:
1.创建客户端SSL配置:
var sslOptions = new SslOptions
{
KeyStorePath = "client.jks",
KeyStorePassword = "password",
TrustStorePath = "trust.jks",
TrustStorePassword = "password",
Protocol = "TLSv1.2",
ClientAuthMode = Ssl.ClientAuthMode.Require
};
其中,KeyStore是客户端的密钥库,TrustStore是客户端的信任库。客户端的密钥库中包含客户端的私钥和证书,信任库中包含客户端需要信任的证书列表。
2.创建客户端配置
var cfg = new IgniteClientConfiguration
{
Host = "127.0.0.1",
Port = 10800,
UseSsl = true,
SslOptions = sslOptions
};
其中,Host和Port是Ignite服务器的地址信息,UseSsl为true表示启用SSL验证,SslOptions为SSL配置。
3.使用前向代理
如果使用前向代理,则需要在客户端SSL配置中设置代理SSl配置:
var sslOptions = new SslOptions
{
ProxyHostName = "proxy-host",
ProxyPort = 10800,
KeyStorePath = "client.jks",
KeyStorePassword = "password",
TrustStorePath = "trust.jks",
TrustStorePassword = "password",
Protocol = "TLSv1.2",
ClientAuthMode = Ssl.ClientAuthMode.Require
};
其中,ProxyHostName和ProxyPort为代理服务器的地址和端口。
4.执行SSL验证
在IgniteThinClient中,SSL验证是自动执行的,不需要额外编写代码。如果SSL验证失败,则会抛出如下异常:
Apache.Ignite.Core.Client.Ssl.SslHandshakeException: 'SSL handshake failed. Remote certificate was not accepted by any of the provided trust managers.'
参考文献: https://apache