[英]SVN Repository Authentication with SharpSVN - Credentials not working
我在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
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.