-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from solarwinds/VT/java_tls12
TLS 1.2 support
- Loading branch information
Showing
7 changed files
with
58 additions
and
20 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
Src/SwqlStudio/ProductSpecific/CertificateValidatorWithCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System.Collections.Generic; | ||
using System.Net.Security; | ||
using System.Security.Cryptography.X509Certificates; | ||
using System.Windows.Forms; | ||
|
||
namespace SwqlStudio | ||
{ | ||
internal static class CertificateValidatorWithCache | ||
{ | ||
// cache positive answers for thumbprints (otherwise, each request fires msgbox) | ||
private static readonly Dictionary<string, bool> _certificateAccepted = new Dictionary<string, bool>(); | ||
|
||
|
||
public static bool ValidateRemoteCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors) | ||
{ | ||
var thumbprint = (certificate as X509Certificate2)?.Thumbprint; | ||
lock (_certificateAccepted) | ||
{ | ||
if (thumbprint != null && | ||
_certificateAccepted.TryGetValue(thumbprint, out var accepted) && | ||
accepted) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
var ret = (DialogResult.Yes == | ||
MessageBox.Show("Server certificate has problem " + sslpolicyerrors + ". Connect anyway?", | ||
"SSL Certificate Issue", MessageBoxButtons.YesNo)); | ||
|
||
lock (_certificateAccepted) | ||
{ | ||
if (thumbprint != null && ret) | ||
{ | ||
_certificateAccepted[thumbprint] = true; | ||
} | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters