Download files from WebDav with certificate via CLI
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
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