我正在尝试使用sharpsvn访问subversion存储库。存储库仅通过HTTPS和机器使用自己的私人证书颁发机构(不要担心此处的安全性,我相信权限)。

我有证书颁发机构的公共根证书,但由于用户访问权限,我无法将证书安装到证书存储中。

如果直接使用subversion,我可以添加:

servers:global:ssl-authority-files=/path/to/cacert.crt
servers:groups:myhost=myhostsdns.com
.

作为命令行对象或配置文件。

如何在sharpsvn中设置这些选项,以便我尝试访问我的存储库时我没有得到“证书验证失败”,并且我不必忽略“证书验证失败”错误?

非常感谢

有帮助吗?

解决方案

它是如何才能在您提出您实现答案的问题之后?

我通过在svnclient对象上设置配置选项来解决这个问题:

SvnClient _svnClient = new SvnClient();
_svnClient.Configuration.SetOption("servers", "global", "ssl-authority-files", "/path/to/cacert.crt");
_svnClient.Configuration.SetOption("servers", "groups", "myhost", "myhostsdns.com");
.

对自助道歉,希望它有助于下一个人。

其他提示

在Bert Huijben的评论中扩展(上图):

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
}
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top