SharpSVN - 服务器证书验证失败

use*_*353 6 c# commit certificate sharpsvn

我使用SharpSVN并在subversion中添加了一个文件夹.然后我尝试提交它,我得到这个例外:

SharpSvn.SvnRepositoryIOException: OPTIONS of 'https://sth.com/svn/blah/Documents': Server certificate verification failed: certificate has expired, certificate issued for a different hostname, issuer is not trusted

据我所见: 服务器证书验证失败

..似乎我必须使用一个--trust-server-cert选项,但我在参数中没有看到这个SvnCommitArgs.

另外,我发现了这个: 如何在不安装证书的情况下在SharpSvn中使用自定义证书颁发机构

我在哪里看到这个:

client.Configuration.SetOption(...)
Run Code Online (Sandbox Code Playgroud)

但我不知道我必须提供什么设置才能使它没有问题.

有没有人做过类似的事情?

编辑:我也试过这样做:

client.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers);

    void Authentication_SslServerTrustHandlers(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e)
    {
        // Accept ceritificate here?
    }
Run Code Online (Sandbox Code Playgroud)

但我不明白我必须在处理程序内接受证书... :(

use*_*353 10

好.我解决了这个问题,现在我又得到了一个错误.你需要做的是:

    client.Authentication.SslServerTrustHandlers += new EventHandler<SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers);
    void Authentication_SslServerTrustHandlers(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e)
    {
        // Look at the rest of the arguments of E, whether you wish to accept

        // If accept:
        e.AcceptedFailures = e.Failures;
        e.Save = true; // Save acceptance to authentication store
    }
Run Code Online (Sandbox Code Playgroud)