-
Notifications
You must be signed in to change notification settings - Fork 466
Load SSL certificate according to git config #512
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
Changes from 24 commits
30f6c15
2477b42
88de9dc
1e4e70c
cac88c7
5035c30
68328ce
c3cdab0
4c6c234
fe9fcb0
08caea1
c69cc57
5a86fb7
cd805fb
2c1cb79
9bceda1
4109b20
16fb49f
7e6a4e8
a8df303
3915d47
a763194
289aea3
4643c3b
482d0fe
9460af4
113d334
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,61 @@ public virtual void RevokeCredential(string repoUrl) | |
| null); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Input for certificate credentials looks like | ||
| /// <code> protocol=cert | ||
| /// path=[http.sslCert value] | ||
| /// username =</code> | ||
| /// </summary> | ||
| public virtual bool TryGetCertificatePassword( | ||
| ITracer tracer, | ||
| string certificatePath, | ||
| out string password, | ||
| out string errorMessage) | ||
| { | ||
| password = null; | ||
| errorMessage = null; | ||
|
|
||
| using (ITracer activity = tracer.StartActivity("TryGetCertificatePassword", EventLevel.Informational)) | ||
| { | ||
| Result gitCredentialOutput = this.InvokeGitAgainstDotGitFolder( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tested this on Windows?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, sadly I do not have access to a windows machine. Do you think something in particular may behave differently here?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prompting for a password from potentially a background process is just a flow we don't have good automation around, which is why I was asking.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jrbriggs @turbonaitis, what is the status of this discussion?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, this doesn't differ from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wilbaker do you agree with this? Or do you think that my changes introduce some additional risks?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @turbonaitis your explanation makes sense to me. @jrbriggs is more familiar with the GCM auth flows and I'd like to hear his thoughts as well. |
||
| "credential fill", | ||
| stdin => stdin.Write("protocol=cert\npath=" + certificatePath + "\nusername=\n\n"), | ||
| parseStdOutLine: null); | ||
|
|
||
| if (gitCredentialOutput.ExitCodeIsFailure) | ||
| { | ||
| EventMetadata errorData = new EventMetadata(); | ||
|
turbonaitis marked this conversation as resolved.
|
||
| errorData.Add("CertificatePath", certificatePath); | ||
| tracer.RelatedWarning( | ||
| errorData, | ||
| "Git could not get credentials: " + gitCredentialOutput.Errors, | ||
| Keywords.Network | Keywords.Telemetry); | ||
| errorMessage = gitCredentialOutput.Errors; | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| password = ParseValue(gitCredentialOutput.Output, "password="); | ||
|
|
||
| bool success = password != null; | ||
|
turbonaitis marked this conversation as resolved.
|
||
|
|
||
| EventMetadata metadata = new EventMetadata | ||
| { | ||
| { "Success", success }, | ||
| { "CertificatePath", certificatePath } | ||
| }; | ||
|
|
||
| if (!success) | ||
| { | ||
| metadata.Add("Output", gitCredentialOutput.Output); | ||
| } | ||
|
|
||
| activity.Stop(metadata); | ||
| return success; | ||
| } | ||
| } | ||
|
|
||
| public virtual bool TryGetCredentials( | ||
| ITracer tracer, | ||
| string repoUrl, | ||
|
|
@@ -259,6 +314,19 @@ public Result SetInFileConfig(string configFile, string settingName, string valu | |
| value)); | ||
| } | ||
|
|
||
| public bool TryGetConfigUrlMatch(string section, string repositoryUrl, out Dictionary<string, GitConfigSetting> configSettings) | ||
| { | ||
| Result result = this.InvokeGitAgainstDotGitFolder($"config --get-urlmatch {section} {repositoryUrl}"); | ||
| if (result.ExitCodeIsFailure) | ||
| { | ||
| configSettings = null; | ||
| return false; | ||
| } | ||
|
|
||
| configSettings = GitConfigHelper.ParseKeyValues(result.Output, ' '); | ||
| return true; | ||
| } | ||
|
|
||
| public bool TryGetAllConfig(bool localOnly, out Dictionary<string, GitConfigSetting> configSettings) | ||
| { | ||
| configSettings = null; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.