2012-12-14 31 views
9

我在C#下面的代码:SVN仓库认证与SharpSVN - 凭据不工作

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 

我在做什么错在这里?我已验证我正在尝试使用的用户名/密码是否有效。

回答

14

我找到了答案...... 5号线后补充一点:

client.Authentication.SslServerTrustHandlers += delegate(object sender, SvnSslServerTrustEventArgs e) { 
        e.AcceptedFailures = e.Failures; 
        e.Save = true; // Save acceptance to authentication store 
       }; 
+1

我得到这个错误:“没有更多的凭据或我们尝试了太多times.Authentication失败” –