2017-06-29 362 views
0

聽起來很簡單,但我無法使其工作。我想通過命令行在窗口上連接到帶有SSL證書的ftp。 所以我生成我與IIS的證書,我將它導出到「CER」格式,並多多嘗試後,我用這個命令行結束:命令行中帶有ssl證書的windows FTP連接

curl -3 -v --cacert "XX\XX\test_certif.cer" --disable-epsv --ftp-skip-pasv-ip --ftp-ssl ftp://XXXXXXX --user XXXX 

後進入我的密碼,我有這樣的錯誤:

Enter host password for user 'XXXXXX': 
* Rebuilt URL to: ftp://XXXX/ 
* Trying XX::XX:XX:XX... 
* TCP_NODELAY set 
* Connected to XXXXX (XX::XX:XX:XX:XX) port 21 (#0) 
< 220 Microsoft FTP Service 
> AUTH SSL 
< 234 AUTH command ok. Expecting TLS Negotiation. 
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH 
* successfully set certificate verify locations: 
* CAfile: XX\XX\test_certif.cer 
CApath: none 
* SSLv3 (OUT), TLS handshake, Client hello (1): 
* Unknown SSL protocol error in connection to XXX:21 
* Closing connection 0 
curl: (35) Unknown SSL protocol error in connection to XXX:21 

我想出來讓它工作。 當我將ftp的ssl參數從「Needed ssl connexion」更改爲「allowed ssl connexion」時,爲了進一步深入我的ftp工作,所以事情不是這樣。 並且Windows防火牆已禁用。

更新我仍然在它的工作,我有現在這個命令行:

curl -v --cacert "XX\XX\test_certif.cer" --ftp-ssl ftp://XXX --user XXX 

與此輸出

Enter host password for user 'XXX': 
* Rebuilt URL to: ftp://XXX 
* Trying XX::XX:XX:XX:XX... 
* TCP_NODELAY set 
* Connected to XXX (XX::XX:XX:XX:XX) port 21 (#0) 
< 220 Microsoft FTP Service 
> AUTH SSL 
< 234 AUTH command ok. Expecting TLS Negotiation. 
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH 
* successfully set certificate verify locations: 
* CAfile: XX\XX\test_certif.cer 
    CApath: none 
* TLSv1.2 (OUT), TLS header, Certificate Status (22): 
* TLSv1.2 (OUT), TLS handshake, Client hello (1): 
* TLSv1.2 (IN), TLS handshake, Server hello (2): 
* TLSv1.2 (IN), TLS handshake, Certificate (11): 
* TLSv1.2 (OUT), TLS alert, Server hello (2): 
* SSL certificate problem: unable to get local issuer certificate 
* Closing connection 0 
* TLSv1.2 (OUT), TLS alert, Client hello (1): 
curl: (60) SSL certificate problem: unable to get local issuer certificate 
More details here: https://curl.haxx.se/docs/sslcerts.html 

curl performs SSL certificate verification by default, using a "bundle" 
of Certificate Authority (CA) public keys (CA certs). If the default 
bundle file isn't adequate, you can specify an alternate file 
using the --cacert option. 
If this HTTPS server uses a certificate signed by a CA represented in 
the bundle, the certificate verification probably failed due to a 
problem with the certificate (it might be expired, or the name might 
not match the domain name in the URL). 
If you'd like to turn off curl's verification of the certificate, use 
the -k (or --insecure) option. 

有任何想法? 隨意問更多信息,如果需要更新問題。 Thx提前

回答

0

我解決了我的問題。問題在於IIS的certificatgénérate沒有使用curl。

所以我使用OpenSSL生成的關鍵:

openssl genrsa -des3 -out key.pem -passout pass:password 1024 

然後仍然使用OpenSSL生成與鍵certificat:

req -x509 -new -key key.pem -passin pass:password -days 3650 -out certificat.cer -config "C:\Program Files (x86)\GnuWin32\share\openssl.cnf" 

-config是沒有必要的需要並且位於您的OpenSSL的文件夾中安裝

現在仍與OpenSSL的,轉換鍵+ certificat以PFX

pkcs12 -inkey key.pem -in certificat.cer -export -out iis_certificate.pfx 

現在您可以將pfx證書導入到IIS並使用它來配置您的FTP連接。

創建一個pem文件並複製過去certificat.cer的內容,或者只是將文件轉換爲pem。讓我們將其命名爲「cacer.pem」

現在使用curl連接:

curl -v ftp://"IP or server name" --user « username » --ftp-ssl --cacert « Path of cacer.pem file » 

這裏是一個小的獎金,在命令行上載在命令行文件,並設置passord:

curl -upload-file 「Path of file to transfert」 ftp://"IP or server name" --user « user »: « password » --ftp-ssl --cacert " Path of cacer.pem file "