Topic "Download files from WebDav with certificate via CLI"

Author Message
Pascal
[View user's profile]

Joined: 2017-10-13
Posts: 1
Hello,

I have a WebDav folder from which I have to download data once a month. I would like to automate that using Powershell and WinSCP.
I already have a saved session for that, which is working properly, but I can find no way to safe the Certificate Passphrase.

The Script Generator gives me this:

# WinSCP .NET assembly laden
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Webdav
HostName = "webdav.remotehost.test"
PortNumber = 443
UserName = "User_Name"
Password = "somepwd$123"
WebdavSecure = $True
TlsClientCertificatePath = "C:\Cert\60654_20171012.p12"

}

$sessionOptions.AddRawSettings("ProxyMethod", "3")
$sessionOptions.AddRawSettings("ProxyHost", "webproxy.company.de")
$sessionOptions.AddRawSettings("ProxyPort", "8080")

$session = New-Object WinSCP.Session

try
{
# Connect
$session.Open($sessionOptions)

# Your code
}
finally
{
$session.Dispose()
}


Hint: I altered personal information but there is a "$" in the Password which cannot be changed and there is a startfolder. The complete URL looks like this https://webdav.remotehost.test/~0000010656/

Running this gives me the following error: SSL handshake failed, client certificate was requested: SSL error: sslv3 alert handshake failure

Does anyone know if there is anyway to get this running?

Thanks

Pascal
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
Use SessionOptions.PrivateKeyPassphrase:
https://winscp.net/eng/docs/library_sessionoptions#privatekeypassphrase
Guest




martin wrote:


Thank you, but there are still some problems.

1. How can I use the Dollar sign in a password? I tried like this "somepwd`$123"
2. How do I specify the Remote directory?
3. I still get the following error: "Server certificate verification failed: issuer is not trusted" is there another option to ignore that?

Thanks.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26890
Location: Prague, Czechia
Quote:
1. How can I use the Dollar sign in a password? I tried like this "somepwd`$123"

Looks ok to me. Do you have any problem with that?

Quote:
2. How do I specify the Remote directory?

For what?

Quote:
3. I still get the following error: "Server certificate verification failed: issuer is not trusted" is there another option to ignore that?

To verify certificates issues by untrusted authority, use SessionOptions.TlsHostCertificateFingerprint:
https://winscp.net/eng/docs/library_sessionoptions#tlshostcertificatefingerprint
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License