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

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

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

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我下面的代碼在我的電腦上運(yùn)行得很好,沒(méi)有代理.但是在客戶端服務(wù)器中,他們需要向 FTP 客戶端 (FileZilla) 添加代理才能訪問(wèn) FTP.但是當(dāng)我添加代理時(shí)它說(shuō)

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

使用代理時(shí)無(wú)法啟用 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 框架確實(shí)不支持通過(guò)代理的 TLS/SSL 連接.

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

您必須使用第 3 方 FTP 庫(kù).

You have to use a 3rd party FTP library.

另外請(qǐng)注意,您的代碼沒(méi)有使用隱式"FTPS.它使用顯式"FTPS..NET 框架也不支持隱式 FTPS.

例如,對(duì)于 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);
}

有關(guān) SessionOptions.AddRawSettings 的選項(xiàng),請(qǐng)參閱 原始設(shè)置.

(我是 WinSCP 的作者)

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

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

相關(guān)文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進(jìn)行身份驗(yàn)證并跨請(qǐng)求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權(quán)不起作用)
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(如何獲取守護(hù)進(jìn)程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問(wèn)令牌和刷新令牌) - IT屋-程序員軟件開(kāi)發(fā)技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問(wèn)令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時(shí) Azure KeyVault Active Directory AcquireTokenAsync 超時(shí))
主站蜘蛛池模板: 高清色| 亚洲国产高清高潮精品美女 | 男女黄网站 | 6080yy精品一区二区三区 | 看片网站在线 | 亚洲激情一区二区 | 精品欧美乱码久久久久久 | 九九九视频精品 | 亚洲国产一区二区在线 | 在线观看国产视频 | 国产亚洲精品美女久久久久久久久久 | 色综合久久久 | 免费 视频 1级 | 亚洲国产精品日韩av不卡在线 | 国产精品色哟哟网站 | 欧美一区二区三区视频在线 | 中文字幕成人 | 在线免费观看a级片 | 日韩在线免费 | 中文一区二区 | 97caoporn国产免费人人 | 超碰精品在线 | 亚洲精品久久久 | 欧洲成人午夜免费大片 | 欧美日韩视频在线第一区 | 日本精品一区 | 国产精品一区二区久久 | 亚洲乱码国产乱码精品精98午夜 | 久久99国产精一区二区三区 | 欧美三级久久久 | 操操日| 99re视频在线观看 | 在线观看黄色电影 | 99视频在线免费观看 | 欧美日韩国产综合在线 | 亚洲精品日日夜夜 | 久久毛片| 国产操操操 | 精品国产一区二区三区性色av | 一级片网址 | 久久久久久久av |