我尝试使用ftp包建立默认的ftps连接:
c, err := ftp.Dial("some_srv:some_port", ftp.DialWithTLS(nil))
if err != nil {
log.Fatal(err)
}
并得到令人惊讶的不言自明的错误:连接:连接被拒绝
文档很糟糕,完全不清楚,如何配置 FTPS,如何组合选项(例如,超时 + TLS=true)。有什么想法吗?)
我无法使
jlaffaye/ftp
工作,但发现了非常古老(9年)的图书馆github.com/webguerilla/ftps
,它的工作就像一个魅力:
ftps := new(ftps.FTPS)
ftps.TLSConfig.InsecureSkipVerify = true
err := ftps.Connect("some_host", 21)
if err != nil {
panic(err)
}
我尝试使用
jlaffaye/ftp
并且不得不使用DialWithExplicitTLS
// Create a TLS configuration.
tlsConfig := &tls.Config{
// Enable TLS 1.2.
InsecureSkipVerify: true,
MinVersion: tls.VersionTLS12,
}
// Connect to the FTP server using TLS encryption.
ftpdialoption := ftp.DialWithExplicitTLS(tlsConfig)
connt, err := ftp.Dial(FTP_ADDR, ftpdialoption)
if err != nil {
log.Fatal(err.Error())
}