使用客户端身份验证证书设置FTPS连接

时间:2016-12-13 15:09:28

标签: ssl curl openssl tls1.2 ftps

我已被要求使用客户端身份验证证书设置FTPS连接。我是客户端,连接到服务器。我在防火墙后面的Windows7工作站上。其他一些信息:

  • 仅限TLS 1.2
  • 仅限被动模式
  • 我的WAN IP已列入白名单
  • 我现在正在连接测试网址
  • 没有出站防火墙(仅限入站规则)
  • 密钥应以PEM格式发送

我从Comodo购买了证书,并用IE10生成了证书。我以.pfx格式从IE导出了完整的证书,包括私钥和扩展属性。

我写了一个小批处理文件,使用OpenSSL从.pfx中提取必要的部分:

::Extract the private key from the PFX
openssl pkcs12 -in comodo.pfx -nocerts -out encrypted.key
::Extract unencrypted private key
openssl rsa -in encrypted.key -out decrypted.key
::Extract the public cert in Base64 from the PFX
openssl pkcs12 -in comodo.pfx -clcerts -nokeys | openssl x509 -out comodo.cer
::Extract the chain bundle from the PFX
openssl pkcs12 -in comodo.pfx -nodes -nokeys -cacerts | openssl x509 -out comodo.crt

使用提取的关键部分,我一直尝试使用各种cURL(v7.46.0)命令连接到FTPS服务器。连接一直失败。我的最新尝试如下。错误几乎总是一样的。

curl -3 -k -v --ftp-ssl --tlsv1.2 --ftp-ssl-reqd --ftp-pasv --key decrypted.key --cacert comodo.crt --cert comodo.cer --user REMOVED:REMOVED ftp://ftps.REMOVED/

输出的一个例子是:

> curl -3 -v -k --user REMOVED:REMOVED --ftp-ssl --tlsv1.2 --ftp-ssl-reqd --ftp-skip-pasv-ip --cert comodo.cer --key priv.pem ftp://ftps.REMOVED/
*   Trying REMOVED_IP.
* Connected to ftps.REMOVED (REMOVED_IP) port 21 (#0)
< 220 Service ready for new user.
> AUTH SSL
< 234 Command AUTH okay; starting SSL connection.
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to ftps.REMOVED:21
* Closing connection 0 curl: (35) Unknown SSL protocol error in connection to ftps.REMOVED:21
>pause
Press any key to continue . . .

奇怪的是,如果我连接FileZilla,我似乎可以通过TLS握手,但是当我尝试上传文件时,我会遇到不同的错误。由于这种联系最终将通过cURL进行,因此我专注于使用cURL。

我已经尝试了一个多星期了。服务器管理员已从我的提供商处购买了证书,并且可以毫无问题地连接。我很难过这个。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

将此问题移至ServerFault,因为该社区似乎有很多类似的主题: https://serverfault.com/questions/820851/debugging-curl-ftps-connection-using-client-authentication-certificates-openss

相关问题