Problem uploading html file to a ftpes server using Rcurl

I´m triying to upload a html file to a server via ftpes using Rcurl but I'm getting this error

library(rmarkdown)
library(RCurl)
library(here)
Sys.setenv(RSTUDIO_PANDOC="/usr/lib/rstudio-server/bin/pandoc")
rmd_path <- here::here("store", "store_data.Rmd")
html_path <- here::here("store", "store_data.html")
render(rmd_path, output_format = "html_document", output_options = c("self_contained = TRUE"), quiet = TRUE)
ftpUpload(html_path, "ftps://<user>:<password>@192.168.1.101:21//var/www/html/kpis.html")
#> Error in function (type, msg, asError = TRUE)  : 
#>     gnutls_handshake() failed: An unexpected TLS packet was received.

This works just fine when TLS wasn't activated, but now I have configured TLS in the ftp server with a self signed certificate.

I finally found the solution, for curl to use explicit TLS on port 21 I have to use "ftp: //" prefix and ftp.ssl = TRUE option. And for curl to accept a self signed certificate, I have to add ssl.verifypeer = FALSE and ssl.verifyhost = FALSE options.

ftpUpload(html_path, "ftp://<user>:<password>@192.168.1.101//var/www/html/kpis.html", ftp.ssl = TRUE, ssl.verifypeer = FALSE, ssl.verifyhost = FALSE)
2 Likes