Search code examples
goftps

Connect to FTPS server with Golang


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?)


Solution

  • 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)
    }