如何使用cURL将FTPS上传到SecureTransport(提示:SITE AUTH和客户端证书)

我试图通过使用gnutls编译的curl通过FTPS连接到SecureTransport 4.5.1。

您需要按照http://curl.haxx.se/mail/lib-2006-07/0068.html使用--ftp-alternative-to-user "SITE AUTH"

你看到我的客户端证书有什么问题吗?

我尝试着

 # mycert.crt -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- # mykey.pem -----BEGIN RSA PRIVATE KEY----- ... -----END RSA PRIVATE KEY----- 

它说“530没有客户证书”:

 myuser@myserver ~ $ curl -v --ftp-ssl --cert mycert.crt --key mykey.pem --ftp-alternative-to-user "SITE AUTH" -T helloworld.txt ftp://ftp.example.com:9876/upload/ * About to connect() to ftp.example.com port 9876 (#0) * Trying 1.2.3.4... connected * Connected to ftp.example.com (1.2.3.4) port 9876 (#0) < 220 msn1 FTP server (SecureTransport 4.5.1) ready. > AUTH SSL < 334 SSLv23/TLSv1 * found 142 certificates in /etc/ssl/certs/ca-certificates.crt > USER anonymous < 331 Password required for anonymous. > PASS [email protected] < 530 Login incorrect. > SITE AUTH < 530 No client certificate presented. * Access denied: 530 * Closing connection #0 curl: (67) Access denied: 530 

我也试过用pk8版本…

 # openssl pkcs8 -in mykey.pem -topk8 -nocrypt > mykey.pk8 -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- 

…但得到完全一样的结果。

发送客户端证书到SecureTransport有什么窍门?

诀窍: 不要使用GnuTLS。 确保你的cURL是用OpenSSL编译的,例如

 $ curl --version curl 7.19.4 (i686-pc-linux-gnu) libcurl/7.19.4 OpenSSL/0.9.8k zlib/1.2.3 Protocols: tftp ftp telnet dict http file https ftps Features: IPv6 Largefile NTLM SSL libz 

我以前曾经重新编译cURL来使用GnuTLS,但是根据邮件列表GnuTLS并没有得到很好的支持 。

自从我在Gentoo之后,我得到了默认的cURL

 sudo USE="-gnutls" emerge curl 

最后,这里是适合我的命令:

 curl --user NameInClientCert:anonymous --ftp-ssl --ftp-ssl-reqd --ftp-pasv --disable-epsv --key mykey.pem --cert mycert.crt -T helloworld.txt ftp://ftp.example.com:9876/upload/ 

(Word的智者:在URL中使用ftp://而不是ftps://)