加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 04:20:20 所属栏目:百科 来源:网络整理
导读:我在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.D
我在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
                };

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读