問(wèn)題描述
使用 FTPS(安全)將文件發(fā)送到帶有 WinSCP(.NET 程序集)的服務(wù)器需要什么?
What is required to send out files to a server with WinSCP (.NET assembly) using FTPS (Secure)?
我一直在查看他們的文檔,但對(duì) TlsHostCertificateFingerprint
或 TlsClientCertificatePath
等某些方面并不是很清楚.
I've been looking at their documentation and am not really clear on certain aspects like TlsHostCertificateFingerprint
or TlsClientCertificatePath
.
我已經(jīng)能夠毫無(wú)問(wèn)題地通過(guò) FTP 和 SFTP 發(fā)送文件,但這整件事讓我無(wú)法理解.
I've been able to send out files via FTP and SFTP with no problem, but this whole thing just eludes me.
推薦答案
如果你有 FTP 的代碼,你只需要添加一個(gè)連接到一個(gè)表現(xiàn)良好的 FTPS (FTP over TLS/SSL) 服務(wù)器就是設(shè)置SessionOptions.FtpSecure
:
If you have a code for FTP, all you need to add to connect to a well-behaved FTPS (FTP over TLS/SSL) server is to set the SessionOptions.FtpSecure
:
// Set up session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "ftp.example.com",
UserName = "username",
Password = "password",
// Enable FTPS in explicit mode, aka FTPES
FtpSecure = FtpSecure.Explicit,
};
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
// Your code
}
<小時(shí)>
TlsHostCertificateFingerprint
僅在您的服務(wù)器證書(shū)未由受信任的機(jī)構(gòu)簽署時(shí)才需要.
The TlsHostCertificateFingerprint
is needed only, if your server certificate is not signed by a trusted authority.
TlsClientCertificatePath
僅在您的服務(wù)器需要使用客戶端證書(shū)進(jìn)行身份驗(yàn)證時(shí)才需要.
The TlsClientCertificatePath
is needed only, if your server requires authenticating with a client certificate.
最簡(jiǎn)單的方法是在 WinSCP GUI 中配置您的會(huì)話 并擁有它為您生成代碼模板.這就是我得到上述代碼的方式.
Easiest is to configure your session in WinSCP GUI and have it generate a code template for you. That's actually how I got the above code.
這篇關(guān)于使用 WinSCP .NET 程序集通過(guò) FTPS(安全)發(fā)送文件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!