Re: SSL Certificates in Windows 7 & Postgres 9.3

From: harpagornis <shenlong(at)runbox(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SSL Certificates in Windows 7 & Postgres 9.3
Date: 2014-12-15 23:25:27
Message-ID: 1418685927656-5830786.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes, I did intend for only SSL connections. The console app must be the
SYSTEM user then, directly or maybe indirectly through the Windows
Certificate Store. I already added root.crt to the trusted certificates
through Windows MMC. Here is my console app, in which I provide the
certificate, so what else needs to be done?
-----------------------------------------------------------------------------
NpgsqlConnection conn = new NpgsqlConnection(conStr);

conn.ProvideClientCertificatesCallback += new
ProvideClientCertificatesCallback(MyProvideClientCertificates);

/*This callback simply returns true indicating you are accepting the server
certificate. Obviously, returning true without doing any validation should
be done for testing purposes only. */

conn.ValidateRemoteCertificateCallback += (a, b, c) => { return true; };
try
{
conn.Open();
System.Console.WriteLine("Connection opened");
}

catch (Exception e)
{
System.Console.WriteLine(e);
}

finally
{
conn.Close();
System.Console.ReadLine();
}
}

private static void MyProvideClientCertificates(X509CertificateCollection
clienteCertis)
{
const string clientcert = "d:\postgrclient.p12";
X509Certificate2 cert = new X509Certificate2(clientcert, "password",
X509KeyStorageFlags.PersistKeySet |
X509KeyStorageFlags.MachineKeySet);

Console.WriteLine(cert.HasPrivateKey);
clienteCertis.Add(cert);
}

--
View this message in context: http://postgresql.nabble.com/SSL-Certificates-in-Windows-7-Postgres-9-3-tp5830749p5830786.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G Johnston 2014-12-15 23:35:37 Re: SSL Certificates in Windows 7 & Postgres 9.3
Previous Message Adrian Klaver 2014-12-15 22:47:57 Re: SSL Certificates in Windows 7 & Postgres 9.3