Self-signed certificate with FTPS and curl in R

0

I want to securely download data in R from an FTP server which supports explicit FTP over SSL. For development and testing of my code, I set up a local FTP server (FileZilla Server) and try to access it from R using the curl library from CRAN. The FTP server uses a self signed certificate which is stored in D:/_git/.../cert.pem (I removed part of the path for this post). I can connect to the server with the FileZilla Client without any problems.

In R, I create the following curl handle:

handle = curl::new_handle(ftp_ssl_ccc = 0,                 # Disables Clear Command Channel in FTP
                          use_ssl = 3,                     # Forces SSL for all traffic
                          ssl_verifyhost = 2,              # Verifies if the host name matches the certificate
                          ssl_verifypeer = 1,              # Verifies the authenticity of the peer's certificate
                          userpwd = "test:testpwd",        # Login credentials
                          cainfo = "D:/_git/.../cert.pem") # Path to the certificate of my server

and I use this call to list the files on the FTP server:

response <- curl_fetch_memory(url = "ftp://localhost/", handle = handle)
return(response$content %>% rawToChar())

However, this does not work. It seems that the certificate I provided with cainfo is not taken into account:

Error in curl_fetch_memory(url = "ftp://localhost/", handle = handle): 
schannel: next InitializeSecurityContext failed: SEC_E_UNTRUSTED_ROOT (0x80090325) - 
The certificate chain was issued by an authority that is not trusted. 

Unfortunately I did not manage to make this work, albeit having tried various things already. Does anyone have an idea how I can make this work (without disabling certificate verification or SSL, of course)? Thanks a lot in advance!


Information about my system:

> version
platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          4                           
minor          0.1                         
year           2020                        
month          06                          
day            06                          
svn rev        78648                       
language       R                           
version.string R version 4.0.1 (2020-06-06)
nickname       See Things Now   

###

> curl::curl_version()
$version
[1] "7.64.1"

$ssl_version
[1] "(OpenSSL/1.1.1a) Schannel"

$libz_version
[1] "1.2.11"

$libssh_version
[1] "libssh2/1.8.2"

$libidn_version
[1] NA

$host
[1] "x86_64-w64-mingw32"

$protocols
 [1] "dict"   "file"   "ftp"    "ftps"   "gopher" "http"   "https"  "imap"   "imaps"  "ldap"   "ldaps"  "pop3"   "pop3s"  "rtsp"   "scp"    "sftp"   "smtp"  
[18] "smtps"  "telnet" "tftp"  

$ipv6
[1] TRUE

$http2
[1] FALSE

$idn
[1] TRUE   
r
ssl
curl
ftp
certificate
asked on Stack Overflow Oct 30, 2020 by nfruehADA

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0