Thanks for sharing your solution.
- martin
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
@sessionlog@
. 2017-02-06 15:38:00.824 Certificate failed to verify against Windows certificate store: Error: 800B0109, Chain index: 0, Element index: -1
@sessionlog@
. 2017-02-06 17:02:40.025 Certificate failed to verify against Windows certificate store: Error: 80092013, Chain index: 0, Element index: 0
The IP Helper service depends on the WinHTTP Web Proxy Auto-Discovery Service service which failed to start because of the following error:
The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.
The Network Connectivity Assistant service depends on the IP Helper service which failed to start because of the following error:
The dependency service or group failed to start.
. 2017-02-13 15:47:41.487 Certificate verified against Windows certificate store
. 2017-02-06 15:38:00.824 Certificate failed to verify against Windows certificate store: Error: 800B0109, Chain index: 0, Element index: -1
. 2017-02-06 17:02:40.025 Certificate failed to verify against Windows certificate store: Error: 80092013, Chain index: 0, Element index: 0
certutil -setreg ca\CRLFlags +CRLF_REVCHECK_IGNORE_OFFLINE
cacert.pem
it works perfectly.
In which part of the Store then I have to put them?
Where WinSCP is looking for those certificates then – in Global storage, Users storage, or may be in some other?
CertVerifyCertificateChainPolicy(CERT_CHAIN_POLICY_SSL, ...)
API that WinSCP uses:
WinSCP DOES USE Windows Certificate store.
No. Use of thecacert.pem
was deliberately never documented. It's not recommended for use.
SFTP/SSH does not use certificates. So all this is irrelevant for SFTP/SSH.
after all investigations I expect that WinSCP does NOT use Windows Certificate Storage.
If the source code from the above link is actual then is it really thatcacert.pem
file is the only place where WinSCP is looking for trusted CA certificates?
cacert.pem
was deliberately never documented. It's not recommended for use.
If all points above are done correctly you don't have to use-hostkey="<fingerprint>"
or-certificate="<fingerprint>"
(I didn't test-hostkey
but I expect it to work) for FTPS/SFTP.
cacert.pem
from the same folder where winscp.exe is placed.
cacert.pem
your commercial or self-signed CA-ROOT and SUB-CA certificates.
-certificate="<fingerprint>"
for FTPS.
cacert.pem
file is the only place where WinSCP is looking for trusted CA certificates?
cacert.pem
is the only way may be you can make this future more flexible so it can be setup throw interface?
Lately I’ve been working on setting up a file server on an Amazon ec2 instance with ProFTPD so that I can upload files using FTPS/SFTP. I had some issues getting FTPS to work correctly despite using a Rapid SSL certificate from GeoTrust that I purchased. I attempted first with FileZilla, and then with WinSCP but both gave me the below error and had problems verifying my SSL certificate.
Unable to get local issuer certificate. The error occurred at a depth of 2 in the certificate chain.
...here some text is cut out...
By looking into the WinSCP code we can check exactly how it is verifying the SSL certificate:
filezilla/AsyncSslSocketLayer.cpp:if (clientMode)
{
USES_CONVERSION;
pSSL_CTX_set_verify(m_ssl_ctx, SSL_VERIFY_PEER, verify_callback);
pSSL_CTX_load_verify_locations(m_ssl_ctx, T2CA(m_CertStorage), 0);
}
filezilla/AsyncSslSocketLayer.cpp:BOOL CAsyncSslSocketLayer::SetCertStorage(CString file)
{
m_CertStorage = file;
return TRUE;
}
filezilla/FtpControlSocket.cpp:m_pSslLayer = new CAsyncSslSocketLayer;
AddLayer(m_pSslLayer);
TCHAR buffer[1000];
GetModuleFileName(NULL, buffer, 1000);
CString filename = buffer;
int pos = filename.ReverseFind(_MPT('\\'));
if (pos != -1)
{
filename = filename.Left(pos + 1);
filename += _T("cacert.pem");
m_pSslLayer->SetCertStorage(filename);
}
else
filename = _MPT("cacert.pem");
So WinSCP uses OpenSSL to verify certificates, the functionpSSL_CTX_load_verify_locations
specifies the location of trusted CA certificates. In this instance we can see that it uses a file calledcacert.pem
in the same location as the running module.
Basically WinSCP does not come with pre-trusted certificates, which is preferable for security reasons but a bit inconvenient as I couldn’t find this information documented. The only information I could find was this which implied that the certificates from the Windows store would be used, and I definitely had the GeoTrust root certificate there.
To fix this I added all the Firefox CAs from https://curl.se/docs/caextract.html
Just download cacert.pem from the above link and place it into the same folder as winscp.exe, then when you try to connect to the server with FTPS that has your certificate you shouldn’t get any certificate warnings.
-certificate="*"
from command line which is run from /script=Script.txt
. 2017-02-01 15:55:49.760 --------------------------------------------------------------------------
. 2017-02-01 15:55:49.766 Connecting to 123.123.123.123:443 ...
. 2017-02-01 15:55:49.942 Connected with 123.123.123.123:443, negotiating TLS connection...
< 2017-02-01 15:55:50.458 220- DataExpress FTP Server ready.
< 2017-02-01 15:55:50.458 220 comForte SecurFTP version SERVER_NAME in FTP server mode
> 2017-02-01 15:55:50.458 AUTH TLS
< 2017-02-01 15:55:50.656 234 SecurFTP: SSL starting
. 2017-02-01 15:55:51.290 Server asks for authentication with a client certificate.
. 2017-02-01 15:55:51.750 Verifying certificate for "ORGANIZATION_NAME" with fingerprint 11:22:33:44:55:66:77:88:99:00:11:22:33:44:55:66:77:88:99:00 and 19 failures
. 2017-02-01 15:55:51.751 Asking user:
. 2017-02-01 15:55:51.751 **The server's certificate is not known. You have no guarantee that the server is the computer you think it is.**
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 Server's certificate details follow:
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 Issuer:
. 2017-02-01 15:55:51.751 - Organization: Delivery External CA
. 2017-02-01 15:55:51.751 - Location: US
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 Subject:
. 2017-02-01 15:55:51.751 - Organization: ORGANIZATION_NAME
. 2017-02-01 15:55:51.751 - Location: US, City
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 Valid: 25.03.2015 21:26:30 - 25.03.2018 21:26:30
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 Fingerprint (SHA-1): 11:22:33:44:55:66:77:88:99:00:11:22:33:44:55:66:77:88:99:00
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 Summary: Self-signed certificate in certificate chain. The error occurred at a depth of 3 in the certificate chain.
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 When connecting using an IP address, it is not possible to verify if the certificate was issued for the server. Use a hostname instead of the IP address.
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 If you trust this certificate, press Yes. To connect without storing certificate, press No. To abandon the connection press Cancel.
. 2017-02-01 15:55:51.751
. 2017-02-01 15:55:51.751 Continue connecting and store the certificate? ()
. 2017-02-01 15:56:01.952 Peer certificate rejected
. 2017-02-01 15:56:01.952 Disconnected from server
. 2017-02-01 15:56:01.952 Connection failed.
-certificate
switch only if the certificate is not signed by a trusted root certificate or if it is a self-signed certificate.
-hostkey="<fingerprint>"
or -certificate="<fingerprint>"
open ftps://martin:mypassword@example.com/ -implicit -certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"