Keep local folder up to date script, certificate problem.

Advertisement

Guest

Keep local folder up to date script, certificate problem.

Hi.
Im a new winscp user. I'm trying to get the included script "keep local folder up to date" to work for me, I've got an issue with certificate. It starts up and displays connecting (which is what the scripts says it shall do). After a couple of seconds (approx 15) it stops and says
Error calling.... system error. code 5. access is denied.
When checking the log it displays my organisations certificate and it displays that it needs confirmation to accept or decline the certificate.
I've searched the forum and found that the command -certificate=* shall solve the problem but I don't know where I shall put it.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,469
Location:
Prague, Czechia

Re: Keep local folder up to date script, certificate problem.

I do not understand what can "system error. code 5. access is denied" have to do with a certificate. Please post logs.

Reply with quote

Guest

Keep local folder up to date script, certificate problem.

Sure, please see below.
. 2023-03-09 13:48:12.361 --------------------------------------------------------------------------
. 2023-03-09 13:48:12.361 WinSCP Version 5.15.3 (Build 9730) (OS 10.0.17134 - Windows 10 Enterprise)
. 2023-03-09 13:48:12.361 Configuration: nul
. 2023-03-09 13:48:12.361 Log level: Normal
. 2023-03-09 13:48:12.361 Local account: computer\?????
. 2023-03-09 13:48:12.361 Working directory: C:\Program Files (x86)\WinSCP
. 2023-03-09 13:48:12.361 Process ID: 14104
. 2023-03-09 13:48:12.361 Command-line: "C:\Program Files (x86)\WinSCP\winscp.exe" /xmllog="C:computer\????? /xmlgroups /xmllogrequired /nointeractiveinput /dotnet=5.15.3  /ini=nul /log="C:\computer\?????\Downloads\KeepLocalUpToDate.log"  /console /consoleinstance=_972_41940948_854
. 2023-03-09 13:48:12.361 Time zone: Current: GMT+1, Standard: GMT+1 (W. Europe Standard Time), DST: GMT+2 (W. Europe Daylight Time), DST Start: 2023-03-26, DST End: 2023-10-29
. 2023-03-09 13:48:12.361 Login time: 09 March 2023 13:48:12
. 2023-03-09 13:48:12.361 --------------------------------------------------------------------------
. 2023-03-09 13:48:12.361 Script: Retrospectively logging previous script records:
> 2023-03-09 13:48:12.361 Script: option batch on
< 2023-03-09 13:48:12.361 Script: batch           on        
< 2023-03-09 13:48:12.361 Script: reconnecttime   120       
> 2023-03-09 13:48:12.361 Script: option confirm off
< 2023-03-09 13:48:12.361 Script: confirm         off       
> 2023-03-09 13:48:12.361 Script: option reconnecttime 120
< 2023-03-09 13:48:12.371 Script: reconnecttime   120       
> 2023-03-09 13:48:12.371 Script: open ftp://seej:***@aaaaa@bbbbb.cccc.com -explicit -passive=1 -timeout=15
. 2023-03-09 13:48:12.371 --------------------------------------------------------------------------
. 2023-03-09 13:48:12.371 Session name: aaaaa@bbbbb.cccc.com (Ad-Hoc site)
. 2023-03-09 13:48:12.371 Host name: aaaaa@bbbbb.cccc.com (Port: 21)
. 2023-03-09 13:48:12.371 User name: aaaaa (Password: Yes, Key file: No, Passphrase: No)
. 2023-03-09 13:48:12.371 Transfer Protocol: FTP
. 2023-03-09 13:48:12.371 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec
. 2023-03-09 13:48:12.371 Disable Nagle: No
. 2023-03-09 13:48:12.371 Proxy: None
. 2023-03-09 13:48:12.371 Send buffer: 262144
. 2023-03-09 13:48:12.371 UTF: Auto
. 2023-03-09 13:48:12.371 FTPS: Explicit TLS/SSL [Client certificate: No]
. 2023-03-09 13:48:12.371 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto
. 2023-03-09 13:48:12.371 Session reuse: Yes
. 2023-03-09 13:48:12.371 TLS/SSL versions: TLSv1.0-TLSv1.2
. 2023-03-09 13:48:12.371 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2023-03-09 13:48:12.371 Cache directory changes: Yes, Permanent: Yes
. 2023-03-09 13:48:12.371 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
. 2023-03-09 13:48:12.371 Timezone offset: 0h 0m
. 2023-03-09 13:48:12.371 --------------------------------------------------------------------------
. 2023-03-09 13:48:12.373 Connecting to aaaaa@bbbbb.cccc.com ...
. 2023-03-09 13:48:12.394 Connected with aaaaa@bbbbb.cccc.com, negotiating TLS connection...
< 2023-03-09 13:48:12.394 220 Microsoft FTP Service
> 2023-03-09 13:48:12.394 AUTH TLS
< 2023-03-09 13:48:12.412 234 AUTH command ok. Expecting TLS Negotiation.
. 2023-03-09 13:48:12.672 Verifying certificate for "" with fingerprint myfingerprint and 20 failures
. 2023-03-09 13:48:12.672 Certificate common name "aaaaa@bbbbb.cccc.com" matches hostname
. 2023-03-09 13:48:27.805 Certificate failed to verify against Windows certificate store: Error: 800B0109, Chain index: 0, Element index: -1
. 2023-03-09 13:48:27.805 Asking user:
. 2023-03-09 13:48:27.805 **The server's certificate is not known. You have no guarantee that the server is the computer you think it is.**
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 Server's certificate details follow:
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 Issuer:
. 2023-03-09 13:48:27.805 - Organization: company Issuing CA 01 - G2
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 Subject:
. 2023-03-09 13:48:27.805 - Organization: aaaaa@bbbbb.cccc.com
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 Valid: 2021-05-06 17:55:05 - 2023-05-06 17:55:05
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 Fingerprint (SHA-1): myfingerprint
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 Summary: Unable to get local issuer certificate. The error occurred at a depth of 2 in the certificate chain.
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 If you trust this certificate, press Yes. To connect without storing certificate, press No. To abandon the connection press Cancel.
. 2023-03-09 13:48:27.805 
. 2023-03-09 13:48:27.805 Continue connecting and store the certificate? ()
. 2023-03-09 13:48:37.815 Peer certificate rejected
. 2023-03-09 13:48:37.815 Disconnected from server
. 2023-03-09 13:48:37.815 Connection failed.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,469
Location:
Prague, Czechia

Re: Keep local folder up to date script, certificate problem.

So you are using WinSCP .NET assembly, right?
I do not see any "system error. code 5. access is denied" in the log.

Anyway, if you want to trust this certificate, set SessionOptions.TlsHostCertificateFingerprint.

Or if you want an equivalent of the insecure -certificate=*, use SessionOptions.GiveUpSecurityAndAcceptAnyTlsHostCertificate.

Reply with quote

Guest

I've now tried adding the session options. it gives me back the same error.
The not its printing "false" before connecting... i guess I'm doing something wrong here..
Please see attached files.

Description: script

winscp_script.png

Description: error code

error_winscp.png

Reply with quote

Advertisement

Guest

Keep local folder up to date script, certificate problem.

Hi Martin.
I manage to get it working. Thanks for the reply.
However I tried the function "delete files" which I assume would delete the files on the remote location after a successful transfer, nothing happened tho, I don't get any information in the PowerShell window and the files are still there. Have I done something wrong or is there more settings that I need to do in order to make it delete the files on the remote location?

Reply with quote

martin
Site Admin
martin avatar

Re: Keep local folder up to date script, certificate problem.

So show us what exactly did you do when you "tried the function "delete files"". And post a session log file.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,469
Location:
Prague, Czechia

Re: Keep local folder up to date script, certificate problem.

The Delete files option does NOT delete the source files. That would defy the very purpose of the "Keep local directory up to date" function.
See https://winscp.net/eng/docs/library_example_keep_local_directory_up_to_date#options

It seems that you are on a wrong track.
You might want to check:
How do I create script that synchronizes files and deletes synchronized files from source afterward?

Reply with quote

Advertisement

You can post new topics in this forum