Exemplo n.º 1
0
        private static void DoConnect(FtpsClient client)
        {
            WriteCredentialsEncryptionWarning();

            CheckPassword();

            var port = _options.port;

            if (port == 0)
            {
                port = (_options.SslRequestSupportMode & ESSLSupportMode.Implicit) == ESSLSupportMode.Implicit ? 990 : 21;
            }

            NetworkCredential credential = null;

            if (!string.IsNullOrEmpty(_options.UserName))
            {
                credential = new NetworkCredential(_options.UserName, _options.password);
            }

            X509Certificate x509ClientCert = null;

            if (_options.sslClientCertPath != null)
            {
                x509ClientCert = X509Certificate.CreateFromCertFile(_options.sslClientCertPath);
            }

            client.Connect(_options.hostName, port,
                           credential,
                           _options.SslRequestSupportMode,
                           ValidateTestServerCertificate,
                           x509ClientCert,
                           _options.sslMinKeyExchangeAlgStrength,
                           _options.sslMinCipherAlgStrength,
                           _options.sslMinHashAlgStrength,
                           _options.timeout * 1000,
                           _options.useCtrlEndPointAddressForData,
                           _options.dataConnectionMode);

            // client.Connect already sets binary by default
            if (_options.transferMode != ETransferMode.Binary)
            {
                client.SetTransferMode(_options.transferMode);
            }

            WriteConnectionInfo(client);

            WriteSslStatus(client);
        }