Last active
December 19, 2015 08:59
-
-
Save franciscojunior/5930034 to your computer and use it in GitHub Desktop.
Npgsql SSL Test program
This file contains hidden or 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
hostssl npgsql_tests all 127.0.0.1/32 trust clientcert=1 |
This file contains hidden or 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
using System; | |
using System.IO; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; | |
using Npgsql; | |
using Mono.Security.Protocol.Tls; | |
using Mono.Security.Authenticode; | |
namespace my | |
{ | |
class Program | |
{ | |
public static string CONNSTRING = "server=127.0.0.1;userid=npgsql_tests;database=npgsql_tests;ssl=true;sslmode=require;"; | |
public static void Main(string[] args) | |
{ | |
NpgsqlConnection conn = new NpgsqlConnection(CONNSTRING); | |
conn.ProvideClientCertificatesCallback += new ProvideClientCertificatesCallback( | |
MyProvideClientCertificates | |
); | |
conn.ValidateRemoteCertificateCallback += (a, b, c) => { return true; }; | |
try | |
{ | |
conn.Open(); | |
System.Console.WriteLine("Verbindung aufgebaut"); | |
} | |
catch (Exception e) | |
{ | |
System.Console.WriteLine(e); | |
} | |
finally | |
{ | |
conn.Close(); | |
System.Console.ReadLine(); | |
} | |
} | |
static void MyProvideClientCertificates(X509CertificateCollection clienteCertis) | |
{ | |
X509Certificate cert = new X509Certificate("postgresql.pfx"); | |
clienteCertis.Add(cert); | |
} | |
} | |
} | |
This file contains hidden or 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
System.IO.IOException: Não é possível ler os dados da conexão de transporte: Foi | |
forçado o cancelamento de uma conexão existente pelo host remoto. ---> System.N | |
et.Sockets.SocketException: Foi forçado o cancelamento de uma conexão existente | |
pelo host remoto | |
em System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, | |
SocketFlags socketFlags) | |
em System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 s | |
ize) | |
--- Fim do rastreamento de pilha de exceções internas --- | |
em System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 s | |
ize) | |
em System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 c | |
ount) | |
em System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offse | |
t, Int32 count, AsyncProtocolRequest asyncRequest) | |
em System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, I | |
nt32 count, AsyncProtocolRequest asyncRequest) | |
em System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, In | |
t32 count, AsyncProtocolRequest asyncRequest) | |
em System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 coun | |
t) | |
em System.IO.BufferedStream.ReadByte() | |
em Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__b.MoveNext() na C:\Us |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment