WebDAV with untrusted SSL cert from .NET

Advertisement

semery
Joined:
Posts:
2

WebDAV with untrusted SSL cert from .NET

WinSCP version: 5.7 (https://winscp.net/download/winscp570automation.zip/download)

I am trying to connect to a WebDAV server with a self-signed certificate using the .NET assembly. I can connect to the same server with the WebDAV protocol on a different port (and with the WinSCP GUI) without SSL but I can't figure out the correct options to set to get SSL working.

If I don't supply the server's host certificate fingerprint, I get the error (as expected):
WinSCP.SessionRemoteException: Server certificate verification failed: certificate issued for a different hostname, issuer is not trusted ---> WinSCP.SessionRemoteException: Connection failed.
If I supply the certificate fingerprint with SessionOptions.TlsHostCertificateFingerprint, I get the error:
System.ArgumentException: SessionOptions.TlsHostCertificateFingerprint or SessionOptions.GiveUpSecurityAndAcceptAnyTlsHostCertificate is set, but SessionOptions.FtpSecure is FtpSecure.None.
So then if I set SessionOptions.FtpSecure to FtpSecure.Implicit, I get the error:
System.ArgumentException: SessionOptions.FtpSecure is not FtpSecure.None, but SessionOptions.Protocol is not Protocol.Ftp.
Is there anything else I can try?

Reply with quote

Advertisement

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

Re: WebDAV with untrusted SSL cert from .Net

Thanks for your report.

That's a bug, will fix it.

Meanwhile, you can download source code of WinSCP and modify the check in Session.SessionOptionsToOpenSwitches.

Instead of
if (sessionOptions.FtpSecure == FtpSecure.None)
use
if ((sessionOptions.FtpSecure == FtpSecure.None) && !sessionOptions.WebdavSecure)

Reply with quote

Advertisement

Advertisement

martin
Site Admin
martin avatar

Re: WebDAV with untrusted SSL cert from .Net

@Peterpan: No idea what you mean. The bug was fixed in 5.7.1, which was released on 2015-03-25 (over a year ago). The current stable version is 5.7.7, released on 2016-03-06.

Reply with quote

Advertisement

You can post new topics in this forum