WebDAV not working via script but works via GUI

Advertisement

michielvandenboogaard
Guest

WebDAV not working via script but works via GUI

Hi, I use WebDAV to download a database-backup from the cloud.
It did work previously, but after the last WinSCP download (and firewall-upgrade) it does not.
Using the GUI it does work, but never on the first try.
I did export the config and compared with my script and tries all sorts of syntaxes, no luck.
CMD:
SET WINSCP="C:\Program Files (x86)\WinSCP\WinSCP.com"
::  get location of this script
SET CURLOC=%~dp0
:: get script with same name in current folder
SET SCRIPT="%CURLOC%%~n0.txt"
:: create log with same name in current folder
SET LOG="%CURLOC%%~n0.log"
:: target file
SET DBFILE="%CURLOC%SQLbackup\topdeskdatabaseNW.bak"
:: Remove old files and start download
IF EXIST %LOG% ( del %LOG%)
IF EXIST %DBFILE% ( del %DBFILE%)
:: Download
%WINSCP% /script=%SCRIPT% /log=%LOG% /parameter // %DBFILE%
:: Replace File
IF EXIST %DBFILE% ( MOVE %DBFILE% "%CURLOC%SQLbackup\topdeskdatabase.bak")
SCRIPT:
#This opens a connection to TOPdesk
open "https://user:pass@***.topdesk.net/webdav/" -certificate=* 
#Changes the working directory in SaaS to the database directory
cd /webdav/database_backup
#Changes the upload method (for performance)
option transfer binary
#Downloads the latest .bak file and rename it to topdeskdatabase.bak
# Please adjust the location (d:\databases\backup) and filename according to your database backup location and preffered database name.
### Databaselocation is passed as parameter from calling CMD ###
get -latest *.bak %1%
#close the connection
close
#Exits the WinSCP file
exit
Logfile:
WinSCP Version 6.3.3 (Build 14916 2024-04-16) (OS 10.0.20348 – Windows Server 2022 Standard)
Configuration: HKCU\Software\Martin Prikryl\WinSCP 2\
Log level: Normal
Local account: RDGG\user
Working directory: D:\Scheduled_Scripts\Topdesk
Process ID: 7004
Ancestor processes: WinSCP, cmd, explorer, ...
Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console=6.3.3 /consoleinstance=_11652_420 "/script=D:\Scheduled_Scripts\Topdesk\WinSCP-DB-Downloadscript.txt" "/log=D:\Scheduled_Scripts\Topdesk\WinSCP-DB-Downloadscript.log" "/parameter" "//" "D:\Scheduled_Scripts\Topdesk\SQLbackup\topdeskdatabaseNW.bak" 
Time zone: Current: GMT+2, Standard: GMT+1 (W. Europe Standard Time), DST: GMT+2 (W. Europe Daylight Time), DST Start: 31-3-2024, DST End: 27-10-2024
Login time: woensdag 24 april 2024 14:49:16
--------------------------------------------------------------------------
Script: Retrospectively logging previous script records:
Script: open https://***:***@***.topdesk.net/webdav/ -certificate=*
--------------------------------------------------------------------------
Session name: ***@***.topdesk.net (Ad-Hoc site)
Host name: ***.topdesk.net (Port: 443)
User name: webdav (Password: Yes, Key file: No, Passphrase: No)
Transfer Protocol: WebDAV
Proxy: None
HTTPS: Yes [Client certificate: No]
WebDAV: Tolerate non-encoded: No
TLS/SSL versions: TLSv1.2-TLSv1.3
Local directory: default, Remote directory: /webdav/, Update: Yes, Cache: Yes
Cache directory changes: Yes, Permanent: Yes
Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
DST mode: Unix
Compression: No
--------------------------------------------------------------------------
Script: Connecting to host...
HTTP session to https://***.topdesk.net:443 begins.
ssl: SNI enabled by default.
auth: Create for WWW-Authenticate
Sending request headers:
OPTIONS /webdav/ HTTP/1.1
 User-Agent: WinSCP/6.3.3 neon/0.33.0
 Keep-Alive: 
 Connection: TE, Keep-Alive
 TE: trailers
 Host: ***.topdesk.net
Sending request-line and headers:
Doing DNS lookup on ***.topdesk.net...
req: Connecting to 104.18.149.7:443
Doing SSL negotiation.
Identity match for '***.topdesk.net': good
Verifying certificate for "topdesk.net" with fingerprint ***** and 08 failures
Certificate for "topdesk.net" matches cached fingerprint and failures
Using TLSv1.3, cipher TLSv1.3: TLS_AES_256_GCM_SHA384, 
Request sent; retry is 0.
ssl: Got TLS closure.
Aborted request (-3): Could not read status line
sess: Closing connection.
ssl: Shutdown state: not sent | received.
ssl: Sending closure.
sess: Connection closed.
Request ends, status 0 class 0xx, error line:
Could not read status line: connection was closed by server
Request ends.
sess: Destroying session.
Script: Could not read status line: connection was closed by server
Connection failed.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,852
Location:
Prague, Czechia

Re: WebDAV not working via script but works via GUI

So do you get the same error in GUI? But on retry it works?
Does any WebDAV client work correctly (on the first try)? And with TLS 1.3?
Anything useful in server-side log file?
Can we have a full hostname of your server, so that we can try on our own?

Reply with quote

michielvandenboogaard
Guest

Re: WebDAV not working via script but works via GUI

Many thanks for your support!
  • hostname is reinierhaga.topdesk.net
  • I do not have access to target-server to look at the logs.
  • Other webdav clients succeed on first try
Tested with CarotDAV and Windows-feature "Webdav redirection",
which I combined to get most of the features of WinSCP I need.

When using WinSCP GUI, first time the screen "hangs" on "Connecting to host"
Finally resulting in Error "Connection failed".

Source-Server has < TLS1.2 disabled.
Handshake of commandline resulted in "Using TLSv1.3, cipher TLSv1.3: TLS_AES_256_GCM_SHA384," according to the log provided.

Does "ssl: Got TLS closure." in the log provided mean "succes" or "failure"?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,852
Location:
Prague, Czechia

Re: WebDAV not working via script but works via GUI

Hm I got expected "403 Forbidden", no TLS error, even on the first try.

What TLS version does CarotDAV use? Did you try TLS 1.2 with WinSCP?
What does first try mean exactly? The first try after some time? The first try after you start WinSCP?

"Got TLS closure" does not mean either.

Reply with quote

Advertisement

You can post new topics in this forum