微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 使用SharpSVN的SVN存储库身份验证 – 凭据不起作用

我在C#中有以下代码
1.  public static void Main(string[] args) {
2.  Uri repository = new Uri("https://svnserver:port/svn/Src/trunk");
3.  using (SvnClient client = new SvnClient()) {                
4.    client.Authentication.Clear();
5.    client.Authentication.DefaultCredentials = new System.Net.NetworkCredential("user","pass");
6.
7.    System.Collections.ObjectModel.Collection<SvnLogEventArgs> logEntries;
8.    SvnLogArgs logArgs = new SvnLogArgs();
9.    logArgs.Limit = 1;
10.   client.GetLog(repository,logArgs,out logEntries);
11.   }
12. }

如果我删除第4行和第5行,这段代码没有任何问题.我假设它是以某种方式使用我保存的凭据在本地从TortoiseSVN.但是,我想在服务器环境中运行,我需要特别传入一个用户名/密码.但是,一旦我尝试放入登录凭据,我在第10行得到以下错误

SharpSvn.SvnRepositoryIOException was unhandled
Message: Unable to connect to a repository at URL

在这里做错了什么?我已经验证了我尝试使用的用户名/密码做工作.

解决方法

我找到答案…添加第5行之后:
client.Authentication.SslServerTrustHandlers += delegate(object sender,SvnSslServerTrustEventArgs e) {
                    e.AcceptedFailures = e.Failures;
                    e.Save = true; // Save acceptance to authentication store
                };

原文地址:https://www.jb51.cc/csharp/91959.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐