Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharpSVN drops connection with an exception before providing credentials #9

Open
HaxtonFale opened this issue Jun 17, 2021 · 3 comments

Comments

@HaxtonFale
Copy link

HaxtonFale commented Jun 17, 2021

I am trying to use SharpSVN to communicate with our repository. I am providing it with credentials but from server-side access logs it looks like they are never used, instead immediately shutting down the connection and throwing a No more credentials or we tried too many times. exception after a single 401 response. Here's our code:

internal static SvnClient SvnClient
{
    get
    {
        if (_svnClient != null) return _svnClient;

        _svnClient = new SvnClient();
        var user = Environment.GetEnvironmentVariable("svnuser");
        var pass = Environment.GetEnvironmentVariable("svnpass");
        if (user != null && pass != null) _svnClient.Authentication.ForceCredentials(user, pass);
        _svnClient.Authentication.SslServerTrustHandlers += (
            (sender, e) =>
            {
                e.AcceptedFailures = SvnCertificateTrustFailures.UnknownCertificateAuthority;
                e.Save = true;
            });

        return _svnClient;
    }
}

private static SvnClient _svnClient;

I tried to increase the number of retries, but I was not able to do so successfully; I tried other methods of injecting credentials as well, but they didn't work either. I can confirm that it's not a cert issue (I've seen cert-related exceptions), that the machine can see the remote repository (I can check it out manually and it works fine when performed by Jenkins), that the credentials are being passed correctly (I printed them out just before these calls and also tried hard-coding them). I tried following the original code but unfortunately C++ is not my strongest suit.

I'm kind of at a loss because it used to work -- but because I do not know how to get the internal state out of the library I cannot check what exactly happens with the client when it tries to talk to the remote repository.

@rhuijben
Copy link
Member

You now only allow a specific failure. In my tests I commonly see more than just that error (e.g. date errors, etc.). You might just want to set to allow other failures too.

Force credentials sets up a high priority username password handler. With debugging these issues it might be easier to explicitly set that handler yourself as that allows more insights in why things fail.

Does a svn ls --no-auth-cache --trust-server-cert --username %SVNUSER% --password %SVNPASS% <url> work for you on the commandline?

It should test exactly what you try to do here, but might provide easier diagnostics... And if it fails this command is fully supported by the Apache Subversion community.

@HaxtonFale
Copy link
Author

Apologies for radio silence! I tried out your suggestion (and I had to throw in --non-interactive with --trust-server-cert). The command ran successfully with the provided credentials.

@PieroB93Impresoft
Copy link

I have this problem too. The command run successfully (adding --non-interactive). I'm using the latest version (1.14001.156).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants