久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 C# 中使用代理連接到 FTPS

Connect to FTPS with proxy in C#(在 C# 中使用代理連接到 FTPS)
本文介紹了在 C# 中使用代理連接到 FTPS的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我下面的代碼在我的電腦上運行得很好,沒有代理.但是在客戶端服務器中,他們需要向 FTP 客戶端 (FileZilla) 添加代理才能訪問 FTP.但是當我添加代理時它說

My below code works perfectly fine in my computer without proxy. But in client server they need to add proxy to the FTP client (FileZilla) to be able to access the FTP. But When I add proxy it says

使用代理時無法啟用 SSL.

SSL cannot be enabled when using a proxy.

FTP 代理

var proxyAddress = ConfigurationManager.AppSettings["ProxyAddress"];
WebProxy ftpProxy = null;
if (!string.IsNullOrEmpty(proxyAddress))
{
   var proxyUserId = ConfigurationManager.AppSettings["ProxyUserId"];
   var proxyPassword = ConfigurationManager.AppSettings["ProxyPassword"];
    ftpProxy = new WebProxy
    {
        Address = new Uri(proxyAddress, UriKind.RelativeOrAbsolute),
        Credentials = new NetworkCredential(proxyUserId, proxyPassword)
    };
 }

FTP 連接

var ftpRequest = (FtpWebRequest)WebRequest.Create(ftpAddress);
ftpRequest.Credentials = new NetworkCredential(
                            username.Normalize(), 
                            password.Normalize()
                         );

ServicePointManager.ServerCertificateValidationCallback += 
   (sender, cert, chain, sslPolicyErrors) => true;

ServicePointManager.Expect100Continue = false;

ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
ftpRequest.EnableSsl = true;
//ftpRequest.Proxy = ftpProxy;
var response = (FtpWebResponse)ftpRequest.GetResponse();

推薦答案

.NET 框架確實不支持通過代理的 TLS/SSL 連接.

.NET framework indeed does not support TLS/SSL connections over proxy.

您必須使用第 3 方 FTP 庫.

You have to use a 3rd party FTP library.

另外請注意,您的代碼沒有使用隱式"FTPS.它使用顯式"FTPS..NET 框架也不支持隱式 FTPS.

例如,對于 WinSCP .NET 程序集,您可以使用:

For example with WinSCP .NET assembly, you can use:

// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Ftp,
    HostName = "example.com",
    UserName = "user",
    Password = "mypassword",
    FtpSecure = FtpSecure.Explicit, // Or .Implicit
};

// Configure proxy
sessionOptions.AddRawSettings("ProxyMethod", "3");
sessionOptions.AddRawSettings("ProxyHost", "proxy");

using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);

    var listing = session.ListDirectory(path);
}

有關 SessionOptions.AddRawSettings 的選項,請參閱 原始設置.

(我是 WinSCP 的作者)

這篇關于在 C# 中使用代理連接到 FTPS的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 亚洲第一中文字幕 | 免费色网址 | 欧美性一区二区三区 | 国产高清在线精品一区二区三区 | 亚洲国产精品一区二区久久 | 成人在线视频网 | 国产福利在线 | 天天干天天操天天看 | 中文字幕日韩一区 | 亚洲天堂影院 | 中文字幕免费 | 精品国产免费人成在线观看 | 成人在线视| 欧美日韩一区二区视频在线观看 | 欧美一区二区在线观看 | 日韩欧美三级在线 | 超碰在线网站 | 日韩三级 | 激情婷婷 | 午夜精品福利视频 | 一区二区三区观看视频 | 黄色一级免费观看 | 91精品国产91久久久久久最新 | 亚洲视频1区| 91精品久久| 老司机67194精品线观看 | 精品久久国产视频 | 国产精品高潮呻吟久久av野狼 | 日韩一区二区三区四区五区六区 | 在线a视频网站 | 亚洲永久 | 6996成人影院网在线播放 | h视频在线观看免费 | 国产欧美日韩二区 | 玖玖玖在线观看 | 国产成人精品一区二 | 999精品视频 | 久久精品91久久久久久再现 | 91欧美激情一区二区三区成人 | 欧美黄色网 | 色片在线观看 |