简体   繁体   English

SVN 凭证

[英]SVN credentials

I have an issue where I keep getting an error我有一个问题,我不断收到错误

No provider registered for 'svn.ssl.server' credentials没有为“svn.ssl.server”凭据注册的提供程序

I am using the same code that works on another SVN server, but a new server I setup can't seem to connect even though I can connect no problem through a web browser.我正在使用与另一台 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());
        }
    }

I have searched for hours for solutions and can't find anything.我已经搜索了几个小时的解决方案,但找不到任何东西。

Both servers are setup with same port, same HTTPS settings and created certificates, same VisualSVN server editions.两台服务器都设置了相同的端口,相同的 HTTPS 设置和创建的证书,相同的 VisualSVN 服务器版本。

I have tried only the one solution that I could find as this is not a common issue at all.我只尝试了我能找到的一种解决方案,因为这根本不是一个常见问题。 This is supposed to fix that error but it doesn't.这应该可以解决该错误,但事实并非如此。

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

I fixed it with adding an event handler for the certificate我通过为证书添加事件处理程序来修复它

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM