Question

I have the following code in 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. }

If I remove lines 4 and 5, this code works without any issue. I'm assuming it's somehow using my saved credentials locally from TortoiseSVN. However, I want to run this in a server environment and I need to specifically pass in a username/password. However, as soon as I attempt to put in the login credentials I get the following error on line 10:

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

What am I doing wrong here? I have verified that the username/password I'm attempting to use do work.

Was it helpful?

Solution

I found the answer... add this after line 5:

client.Authentication.SslServerTrustHandlers += delegate(object sender, SvnSslServerTrustEventArgs e) {
                    e.AcceptedFailures = e.Failures;
                    e.Save = true; // Save acceptance to authentication store
                };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top