Created
April 29, 2019 21:21
-
-
Save yavor87/216b73b2e2e04e540c8568129f178420 to your computer and use it in GitHub Desktop.
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
public class Startup { | |
private string clientCertPath; | |
} | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddDbContext<DataAccess.ClientDatabaseContext>(options => | |
options.UseNpgsql(this.connectionString, opt => { | |
opt.RemoteCertificateValidationCallback(RemoteCertificateValidation); | |
opt.UseAdminDatabase("defaultdb"); | |
})); | |
} | |
private bool RemoteCertificateValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) | |
{ | |
X509Chain chain0 = new X509Chain(); | |
chain0.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; | |
// add all your extra certificate chain | |
chain0.ChainPolicy.ExtraStore.Add(new X509Certificate2(this.clientCertPath)); | |
chain0.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority; | |
return chain0.Build((X509Certificate2)certificate); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment