-
Notifications
You must be signed in to change notification settings - Fork 2
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
Accept non-trusted certificates option #100
Changes from all commits
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 |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
using Task = System.Threading.Tasks.Task; | ||
using Microsoft.VisualStudio.TaskStatusCenter; | ||
using SolutionEvents = Microsoft.VisualStudio.Shell.Events.SolutionEvents; | ||
using System.Net; | ||
|
||
namespace Cody.VisualStudio | ||
{ | ||
|
@@ -286,6 +287,7 @@ private void PrepareAgentConfiguration() | |
RestartAgentOnFailure = true, | ||
ConnectToRemoteAgent = devPort != null, | ||
RemoteAgentPort = portNumber, | ||
AcceptNonTrustedCertificates = UserSettingsService.AcceptNonTrustedCert, | ||
Debug = true | ||
}; | ||
|
||
|
@@ -376,6 +378,7 @@ private void InitializeAgent() | |
{ | ||
try | ||
{ | ||
await TestServerConnection(UserSettingsService.ServerEndpoint); | ||
AgentClient.Start(); | ||
|
||
var clientConfig = GetClientInfo(); | ||
|
@@ -449,6 +452,35 @@ private void OnAfterCloseSolution(object sender, EventArgs e) | |
} | ||
} | ||
|
||
private async Task TestServerConnection(string serverAddress) | ||
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. Would be great to add modal dialog that will show the warning, and two options button, like: "Do you want to change non-trusted certificate policy?" "SSL certificate problem: self-signed certificate in servers certificate chain. Consider using 'Accept non-trusted certificates' option in Cody settings window."
After clicking the first button, we will display the options page via |
||
{ | ||
if (string.IsNullOrWhiteSpace(serverAddress)) return; | ||
|
||
using (WebClient webClient = new WebClient()) | ||
{ | ||
try | ||
{ | ||
await webClient.DownloadStringTaskAsync(serverAddress); | ||
} | ||
catch (WebException ex) when (ex.Status == WebExceptionStatus.TrustFailure) | ||
{ | ||
if (!UserSettingsService.AcceptNonTrustedCert) | ||
{ | ||
AgentLogger.Warn("SSL certificate problem: self-signed certificate in servers certificate chain. " + | ||
"Consider using 'Accept non-trusted certificates' option in Cody settings window."); | ||
} | ||
else | ||
{ | ||
AgentLogger.Warn("SSL certificate problem."); | ||
} | ||
} | ||
catch | ||
{ | ||
AgentLogger.Warn($"Connection problem with '{serverAddress}'"); | ||
} | ||
} | ||
} | ||
|
||
|
||
private void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed. Only TextBox controls do need those additional binding calls.