public static NetworkCredential LookupCredential(this ICredentialsByHost credentials, ConnectionBase connection, string username, IStringEnum authenticationMechanism) { if (connection == null) throw new ArgumentNullException("connection"); return LookupCredential(credentials, connection.Host, connection.Port, username, authenticationMechanism == null ? null : authenticationMechanism.Value); }
public static Stream CreateClientSslStream(ConnectionBase connection, Stream baseStream, X509Certificate2Collection clientCertificates, RemoteCertificateValidationCallback serverCertificateValidationCallback, LocalCertificateSelectionCallback clientCertificateSelectionCallback) { var sslStream = new SslStream(baseStream, false, serverCertificateValidationCallback, clientCertificateSelectionCallback); try { sslStream.AuthenticateAsClient(connection.host, clientCertificates, SslProtocols.Default, true); return sslStream; } catch (AuthenticationException) { sslStream.Close(); throw; } }