SVN Repository Authentication with SharpSVN - Credentials not working
Asked Answered
K

1

10

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.

Kronstadt answered 14/12, 2012 at 23:24 Comment(0)
K
15

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
                };
Kronstadt answered 15/12, 2012 at 0:57 Comment(1)
I'm getting this error: "No more credentials or we tried too many times.Authentication failed"Ator

© 2022 - 2024 — McMap. All rights reserved.