Connect to FTPS server with Golang

huangapple go评论118阅读模式
英文:

Connect to FTPS server with Golang

问题

我尝试使用ftp包建立默认的ftps连接:

c, err := ftp.Dial("some_srv:some_port", ftp.DialWithTLS(nil))

if err != nil {
    log.Fatal(err)
}

然后得到了令人惊讶的自解释错误:连接被拒绝。

文档非常糟糕,完全不清楚如何配置FTPS,如何组合选项(例如,超时+TLS=true)。有什么想法吗?

英文:

I try to use ftp package to establish default ftps connection:

c, err := ftp.Dial("some_srv:some_port", ftp.DialWithTLS(nil))

if err != nil {
	log.Fatal(err)
}

and get astonishing self-explaining error: connect: connection refused

The documentation is awful, it's absolutely not clear, how to configure FTPS, how to combine options (for instance, timeout + TLS=true). Any ideas?)

答案1

得分: 1

我无法使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)
}
英文:

I wasn't able to make jlaffaye/ftp working, but found very old (9 years) library github.com/webguerilla/ftps and it works like a charm:

ftps := new(ftps.FTPS)
ftps.TLSConfig.InsecureSkipVerify = true

err := ftps.Connect("some_host", 21)
if err != nil {
	panic(err)
}

huangapple
  • 本文由 发表于 2023年2月7日 23:08:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75375260.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定