Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Couldn't connect to remote git repository. #50

Closed
biifer opened this issue Sep 20, 2015 · 3 comments
Closed

Couldn't connect to remote git repository. #50

biifer opened this issue Sep 20, 2015 · 3 comments

Comments

@biifer
Copy link

biifer commented Sep 20, 2015

I host my repo on my own gitlab git server but I can't get it to work. Are there any logs that I can check for more details? I have no problem accessing the repo via the browser.
I'm on Windows 10.
pass4win-error

@biifer
Copy link
Author

biifer commented Sep 20, 2015

Looking through the event log I find this error: (Translated from Swedish)

Application programs: Pass4Win.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Details: LibGit2Sharp.RepositoryNotFoundException Stack: at LibGit2Sharp.Repository..ctor (System.String, LibGit2Sharp.RepositoryOptions) at Pass4Win.frmMain..ctor () at Pass4Win.Program.Main ()

@biifer
Copy link
Author

biifer commented Sep 20, 2015

It's something to do with the CredentialProvider. If I edit the source myself and set hard coded values it works correctly. I'm no C# developer but I'll try to figure out what's going on here...

                fetchOptions.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials
                {
                    Username = "ivan",
                    Password = "supersecretpassword"
                };

@mbos
Copy link
Owner

mbos commented Sep 20, 2015

Good work.
The only thing that could cause this are the EncryptConfig() and DecryptConfig() functions if you debug it you could probably see how your password get's mangled. I suspect it has to do with using the unicode encoding:

        /// Encrypt the git password
        /// </summary>
        /// <param name="password"></param>
        /// <param name="salt"></param>
        /// <returns></returns>
        static public string EncryptConfig(string password, string salt)
        {
            byte[] passwordBytes = Encoding.Unicode.GetBytes(password);
            byte[] saltBytes = Encoding.Unicode.GetBytes(salt);
            byte[] cipherBytes = ProtectedData.Protect(passwordBytes, saltBytes, DataProtectionScope.CurrentUser);

            return Convert.ToBase64String(cipherBytes);
        }

        /// <summary>
        /// decrypts the git password
        /// </summary>
        /// <param name="cipher"></param>
        /// <param name="salt"></param>
        /// <returns></returns>
        static public string DecryptConfig(string cipher, string salt)
        {
            byte[] cipherBytes = Convert.FromBase64String(cipher);
            byte[] saltBytes = Encoding.Unicode.GetBytes(salt);
            byte[] passwordBytes = ProtectedData.Unprotect(cipherBytes, saltBytes, DataProtectionScope.CurrentUser);

            return Encoding.Unicode.GetString(passwordBytes);

So basically making here unicode in utf8 might work....
Let me know if this is the case.

@mbos mbos closed this as completed Oct 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants