gpt4 book ai didi

c# - SVN 凭据

转载 作者:行者123 更新时间:2023-12-04 22:41:01 31 4
gpt4 key购买 nike

我有一个问题,我不断收到错误
没有为“svn.ssl.server”凭据注册的提供者
我正在使用在另一台 SVN 服务器上工作的相同代码,但我设置的新服务器似乎无法连接,即使我可以通过 Web 浏览器连接没有问题。

    //SVN Client repo sync

public void DownloadSVNStartup(string url, string path)
{

using (SvnClient client = new SvnClient())
{
try
{
client.CleanUp(path); //will go to catch block since there's no working copy yet I
//want to checkout for the first time then next time this part
//will work.
SvnUI.Bind(client, this);
SvnCheckOutArgs sco = new SvnCheckOutArgs();
sco.AllowObstructions = false;
}
catch (Exception ex)
{
MessageBox.Show("Line 88");
MessageBox.Show(ex.ToString());
myLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}

client.Configuration.SetOption("servers", "global", "http-auth-types", "basic;digest");
client.Authentication.Clear();
client.Authentication.ForceCredentials("user", "password");

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

Object[] args = { url, path };
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += backgroundWorker1_DoWork;
worker.RunWorkerAsync(args);
this.Hide();

}
catch (Exception ex)
{
MessageBox.Show("Line126");
MessageBox.Show(ex.ToString());
myLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
}
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) //connect to the Svn
//server
{
try

{
Object[] arg = e.Argument as Object[];
string url = (string)arg[0];
string path = (string)arg[1];

using (SvnClient client = new SvnClient())
{
client.Authentication.Clear(); // Prevents saving/loading config to/from disk
client.Authentication.ForceCredentials("user", "password");
client.CheckOut(new Uri(url), path); //fails here with the error No provider registered for 'svn.ssl.server' credentials
client.CleanUp(path);
client.Update(path);
client.CleanUp(path);
}
}

catch (Exception ex)
{
MessageBox.Show("Line166", ex.Message.ToString());
MessageBox.Show(ex.ToString());
}
}
我已经搜索了几个小时的解决方案,但找不到任何东西。
两台服务器都设置有相同的端口、相同的 HTTPS 设置和创建的证书、相同的 VisualSVN 服务器版本。
我只尝试了我能找到的一种解决方案,因为这根本不是一个常见问题。
这应该可以解决该错误,但事实并非如此。
     client.Authentication.SslServerTrustHandlers += delegate (object sender, SvnSslServerTrustEventArgs e)
{
e.AcceptedFailures = e.Failures;
e.Save = false; // Save acceptance to authentication store
};

最佳答案

我通过为证书添加事件处理程序来修复它

     private void SslClientCertificateHandlers(object sender, SvnSslClientCertificateEventArgs e)
{
e.Save = true;
e.CertificateFile = @"where you want to save certs";
}

关于c# - SVN 凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63198193/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com