c# - SVN 凭据

标签 c# ssl svn certificate sharpsvn

我有一个问题,我不断收到错误
没有为“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/

相关文章:

linux - SVN Hook pre-revprop-change 不工作

svn - Visual Studio 6 SVN 插件

svn - 安卓工作室 : Subversion files are marked as unversioned

C# 数据读取器值在调试时重复多次

c# - 在 ListView 控件中查找控件

ssl - 客户端证书提示不显示nginx

android - 如何使用与 KMS 的安全 SSL 连接在 Android 上使用您自己的 "Tomcat signalling server"实现 Kurento Client JS?

c# - 在数组队列上使用 Contains 时,控制台返回 False。为什么?

c# - 这样显示菜单方便吗?

security - Jetty 9.4.18 中的 SSL 是否必须使用主题备用名称