77using System . Threading ;
88using System . Threading . Tasks ;
99using Halibut . Diagnostics ;
10+ using Halibut . Transport . Observability ;
1011using Halibut . Transport . Protocol ;
1112using Halibut . Transport . Proxy ;
1213using Halibut . Transport . Streams ;
@@ -20,12 +21,19 @@ public class TcpConnectionFactory : IConnectionFactory
2021 readonly X509Certificate2 clientCertificate ;
2122 readonly HalibutTimeoutsAndLimits halibutTimeoutsAndLimits ;
2223 readonly IStreamFactory streamFactory ;
24+ readonly ISecureConnectionObserver secureConnectionObserver ;
2325
24- public TcpConnectionFactory ( X509Certificate2 clientCertificate , HalibutTimeoutsAndLimits halibutTimeoutsAndLimits , IStreamFactory streamFactory )
26+ public TcpConnectionFactory (
27+ X509Certificate2 clientCertificate ,
28+ HalibutTimeoutsAndLimits halibutTimeoutsAndLimits ,
29+ IStreamFactory streamFactory ,
30+ ISecureConnectionObserver secureConnectionObserver
31+ )
2532 {
2633 this . clientCertificate = clientCertificate ;
2734 this . halibutTimeoutsAndLimits = halibutTimeoutsAndLimits ;
2835 this . streamFactory = streamFactory ;
36+ this . secureConnectionObserver = secureConnectionObserver ;
2937 }
3038
3139 public async Task < IConnection > EstablishNewConnectionAsync ( ExchangeProtocolBuilder exchangeProtocolBuilder , ServiceEndPoint serviceEndpoint , ILog log , CancellationToken cancellationToken )
@@ -60,6 +68,13 @@ await ssl.AuthenticateAsClientAsync(
6068 await ssl . FlushAsync ( cancellationToken ) ;
6169
6270 log . Write ( EventType . Security , "Secure connection established. Server at {0} identified by thumbprint: {1}, using protocol {2}" , client . Client . RemoteEndPoint , serviceEndpoint . RemoteThumbprint , ssl . SslProtocol . ToString ( ) ) ;
71+ secureConnectionObserver . SecureConnectionEstablished (
72+ new SecureConnectionInfo
73+ {
74+ ConnectionDirection = ConnectionDirection . Outgoing ,
75+ SslProtocols = ssl . SslProtocol
76+ }
77+ ) ;
6378
6479 return new SecureConnection ( client , ssl , exchangeProtocolBuilder , halibutTimeoutsAndLimits , log ) ;
6580 }
0 commit comments