"LibGit2Sharp.LibGit2SharpException: could not initialize security context" while cloning
avy99 opened this issue · 6 comments
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
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?
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
@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?
@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)
@ethomson please find the requested details:
private repo
self signed certificate
basic authentication.
@ethomson any update on it
@happy2ganesh were u able to resolve the issue, if so, some help would be highly appreciable