简体   繁体   中英

SVN credentials

I have an issue where I keep getting an error

No provider registered for 'svn.ssl.server' credentials

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 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.

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";
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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