Esempio n. 1
0
        private async Task <FluentFTP.FtpClient> CreateClient(Uri uri)
        {
            if (_cacheClient == null ||
                !_cacheClient.IsConnected ||
                !_cacheClient.IsAuthenticated)
            {
                var port   = uri.Port == -1 ? 21 : uri.Port;
                var client = new FluentFTP.FtpClient(uri.Host, port, Credential?.UserName, Credential?.Password);
                client.ValidateAnyCertificate = true;
                await client.AutoConnectAsync();

                _cacheClient = client;
                _log.Information("Established connection with ftp server at {host}:{port}, encrypted: {enc}", uri.Host, port, _cacheClient.IsEncrypted);
            }
            return(_cacheClient);
        }