首页 > 解决方案 > WinSCP - 自动接受任何证书

问题描述

我正在使用带有如下脚本文件的 WinSCP 命令行实用程序(从 SSIS 启动):

option confirm off
open ftps://user:pw@ftp.host.com:3221/root -certificate=*
put \\path\to\file\Stores.zip
put \\path\to\file\Products.zip
put \\path\to\file\Inventory.zip
exit

当我运行它时,它没有完成 - 如果我检查日志,我会看到:

. 2018-05-11 10:27:16.413 Connecting to ftp.host.com:3221 ...
. 2018-05-11 10:27:16.546 Connected with ftp.host.com:3221, negotiating SSL connection...
. 2018-05-11 10:27:17.044 Asking user:
. 2018-05-11 10:27:17.045 The server's certificate is not known. You have no guarantee that the server is the computer you think it is. Server's certificate details follow:
. 2018-05-11 10:27:17.045 
. 2018-05-11 10:27:17.046 Issuer:
. 2018-05-11 10:27:17.047 - Organization: Host, Inc., *.host.com
. 2018-05-11 10:27:17.048 - Location: US, State, City
. 2018-05-11 10:27:17.048 
. 2018-05-11 10:27:17.053 Subject:
. 2018-05-11 10:27:17.058 - Organization: CertOrg
. 2018-05-11 10:27:17.060 - Location: US
. 2018-05-11 10:27:17.066 
. 2018-05-11 10:27:17.068 Valid: 7/14/2017 12:00:00 AM - 8/29/2018 12:00:00 PM
. 2018-05-11 10:27:17.074 
. 2018-05-11 10:27:17.075 Fingerprint (SHA1): ##################
. 2018-05-11 10:27:17.075 
. 2018-05-11 10:27:17.076 Summary: Unable to get local issuer certificate. The error occured at a depth of 1 in the certificate chain.
. 2018-05-11 10:27:17.076 
. 2018-05-11 10:27:17.077 If you trust this certificate, press Yes. To connect without storing certificate, press No. To abandon the connection press Cancel.
. 2018-05-11 10:27:17.080 
. 2018-05-11 10:27:17.081 Continue connecting and store the certificate? ()

根据-certificate=*我在文档中收集的内容,应该自动推动接受。我在这里缺少什么吗?我也尝试过hostkey=*产生相同的结果,并且同时使用主机密钥和证书标志会导致错误。

任何帮助是极大的赞赏。

标签: certificatewinscpftps

解决方案


如果没有看到完整的会话日志文件,很难回答这个问题。

但我的猜测是你使用了一些不支持*in -certificate(早于 5.2)或根本不支持-certificateswitch(早于 4.2.2)的旧版本的 WinSCP。

使用最新版本的 WinSCP,您的脚本应该可以正常工作。


不用说,通过使用*,您将失去对MITM 攻击的保护!


推荐阅读