mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 14:51:44 +01:00
Added: Simple TLS
This commit is contained in:
parent
9103a5959f
commit
fbdbc90f1d
@ -10,6 +10,9 @@ using Borepin.Service.BFFH.Exceptions;
|
||||
using Borepin.Service.Storage.Exceptions;
|
||||
using Capnp.Rpc;
|
||||
using FabAccessAPI.Exceptions;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
|
||||
namespace Borepin.Service.BFFH
|
||||
{
|
||||
@ -278,9 +281,29 @@ namespace Borepin.Service.BFFH
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
private static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private async Task<TcpRpcClient> _ConnectAsync(string host, int port)
|
||||
{
|
||||
TcpRpcClient rpcClient = new TcpRpcClient();
|
||||
rpcClient.InjectMidlayer((tcpstream) =>
|
||||
{
|
||||
|
||||
var sslStream = new SslStream(tcpstream, false, new RemoteCertificateValidationCallback(RemoteCertificateValidationCallback));
|
||||
try
|
||||
{
|
||||
sslStream.AuthenticateAsClient("bffhd");
|
||||
return sslStream;
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{
|
||||
sslStream.Close();
|
||||
throw;
|
||||
}
|
||||
});
|
||||
rpcClient.Connect(host, port);
|
||||
await rpcClient.WhenConnected.ConfigureAwait(false);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user