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

"LibGit2Sharp.LibGit2SharpException: could not initialize security context" while cloning #2108

Open
avy99 opened this issue Jul 8, 2024 · 6 comments

Comments

@avy99
Copy link

avy99 commented Jul 8, 2024

Reproduction steps

providing valid credential to the CredentialProvider using the below snippet
cloneOptions.FetchOptions.CredentialsProvider = (url, usernameFromUrl, password) =>
new UsernamePasswordCredentials{ Username = gitCredential.UserName, Password = gitCredential.Password };

cloneOptions.FetchOptions.CertificateCheck = (certificate, valid, host) => true;

Repository.Clone(Credential.RepositoryUrl, workingDirectory, cloneOptions);

Expected behavior

Should clone the repository to the working directory.

Actual behavior

LibGit2Sharp.LibGit2SharpException: could not initialize security context:
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 154
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /
/LibGit2Sharp/Core/Ensure.cs:line 172
at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts) in //LibGit2Sharp/Core/Proxy.cs:line 278
at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options) in /
/LibGit2Sharp/Repository.cs:line 824

Version of LibGit2Sharp (release number or SHA1)

v0.30.0

Operating system(s) tested; .NET runtime tested

.NET8, windows OS

@ethomson
Copy link
Member

ethomson commented Jul 8, 2024

What are you trying to clone from? GitHub.com? GHES? On prem azure devops? Hosted Azure DevOps? Something else?

Does it have a valid SSL cert or is it self signed?

What sort of auth mechanism is it trying to use? Basic? Kerberos? Something else?

@happy2ganesh
Copy link

i am also facing the same error during git clone by using libgit2sharp version 0.30
i am able to do git clone from cmd line script inside the server.
facing "could not initialize security context: The parameter is incorrect." error while trying to clone from libgit2sharp only

@ethomson
Copy link
Member

@happy2ganesh Same questions if you can help:

What are you trying to clone from? GitHub.com? GHES? On prem azure devops? Hosted Azure DevOps? Something else?

Does it have a valid SSL cert or is it self signed?

What sort of auth mechanism is it trying to use? Basic? Kerberos? Something else?

@avy99
Copy link
Author

avy99 commented Jul 10, 2024

@ethomson
below are the details:
Cloning from, a private repository
it is self-signed
Auth mechanism is Basic

Another thing to mention is while testing it using "libgit2sharp-proxy-enabled" Version="0.0.0-preview.0.1901"
it is able to clone the repository successfully
(minor adjustment is made to adapt clone option changes)

@happy2ganesh
Copy link

@ethomson please find the requested details:
private repo
self signed certificate
basic authentication.

@avy99
Copy link
Author

avy99 commented Aug 7, 2024

@ethomson any update on it
@happy2ganesh were u able to resolve the issue, if so, some help would be highly appreciable

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