[Eppnicbr] RES: RES: RES: RES: RES: RES: RES: Acesso TLS

Felipe Rodrigues Pereira felipe.pereira at tecla.com.br
Wed Apr 9 17:04:28 BRT 2008


Eduardo na implantação da classe esta ocorrendo alguns erros, você pode me
adicionar no MSN: lipe_hc1 at hotmail.com, quer fazer algumas perguntas!
Obrigado pela atenção!

 

De: eppnicbr-bounces at eng.registro.br
[mailto:eppnicbr-bounces at eng.registro.br] Em nome de Carlos Eduardo Fontes
Silva
Enviada em: quarta-feira, 9 de abril de 2008 10:54
Para: EPP no .br - protocolo e operacao
Assunto: Re: [Eppnicbr] RES: RES: RES: RES: RES: RES: Acesso TLS

 

Felipe,

 

Segue um exemplo usando .Net Framework 2.0 e de graça!

Lembrando que gerei os certificados “DER” com os arquivos client.pem e
root.pem com openssl.

 

using System;

using System.Collections.Generic;

using System.Text;

using System.Net.Security;

using System.Net.Sockets;

using System.Security.Cryptography;

using System.Security.Cryptography.X509Certificates;

 

namespace EPP_Test_Console

{

            class EppSSL

            {

                        [STAThread]

                        static void Main(string[] args)

                        {

                                    EppSSL ssl = new EppSSL();

                                    ssl.run();

                        }

 

                        public void run()

                        {

                                    TcpClient client = new TcpClient();

                                    client.Connect("beta.registro.br", 700);

                                    SslStream sslStream = new
SslStream(client.GetStream(), false, new
RemoteCertificateValidationCallback(CertificateValidationCallback));

 

                                    X509Certificate x509 =
X509Certificate.CreateFromCertFile(@"E:\cert\client.der");

                                    X509Certificate x5091 =
X509Certificate.CreateFromCertFile(@"E:\cert\root.der");

 

 

                                    X509CertificateCollection certs = new
X509CertificateCollection();

                                    certs.Add(x509);

                                    certs.Add(x5091);

 

 
sslStream.AuthenticateAsClient("beta.registro.br", certs,

 
System.Security.Authentication.SslProtocols.Tls, false);

 

                                    // Get the response.

                                    // Buffer to store the response bytes.

                                    byte[] bytes = new byte[1024];

 

                                    // Display the response.

 

                                    int bytesRead = sslStream.Read(bytes, 0,
bytes.Length);

                                    string serverResponse =
Encoding.ASCII.GetString(bytes, 0,

                                                  bytesRead);

                                    Console.WriteLine("Server said: " +
serverResponse);

                                    Console.Read();

 

                        }

 

                        private bool CertificateValidationCallback(object
sender,

 
X509Certificate certificate,

 
X509Chain chain,

 
SslPolicyErrors sslPolicyErrors)

                        {

                                    if (sslPolicyErrors ==
SslPolicyErrors.None)

                                    {

                                                return true;

                                    }

                                    else

                                    {

                                                if (sslPolicyErrors ==
SslPolicyErrors.RemoteCertificateChainErrors)

                                                {

 
Console.WriteLine("The X509Chain.ChainStatus returned an array " +

                                                               "of
X509ChainStatus objects containing error information.");

                                                }

                                                else if (sslPolicyErrors ==

 
SslPolicyErrors.RemoteCertificateNameMismatch)

                                                {

 
Console.WriteLine("There was a mismatch of the name " +

                                                              "on a
certificate.");

                                                }

                                                else if (sslPolicyErrors ==

 
SslPolicyErrors.RemoteCertificateNotAvailable)

                                                {

 
Console.WriteLine("No certificate was available.");

                                                }

                                                else

                                                {

 
Console.WriteLine("SSL Certificate Validation Error!");

                                                }

                                    }

 

                                    Console.WriteLine(Environment.NewLine +

 
"SSL Certificate Validation Error!");

 
Console.WriteLine(sslPolicyErrors.ToString());

 

                                    return false;

                        }

 

            }

 

}

 

[]s

 

Carlos Eduardo

 

  _____  

From: eppnicbr-bounces at eng.registro.br
[mailto:eppnicbr-bounces at eng.registro.br] On Behalf Of Fernando Rotermund
Sent: terça-feira, 8 de abril de 2008 09:24
To: EPP no .br - protocolo e operacao
Subject: Re: [Eppnicbr] RES: RES: RES: RES: RES: RES: Acesso TLS

 

Muda pra linux que fica mais facil.

Deve existir sim alguem que ja tenha feito isso em .net, mas se eu conheço
bem a ideologia do .net esta informação não será de graça.

A maioria foi implementada em linux porque é mais facil.

 

[]s

----- Original Message ----- 

From: Felipe Rodrigues Pereira <mailto:felipe.pereira at tecla.com.br>  

To: eppnicbr at eng.registro.br 

Sent: Monday, April 07, 2008 1:32 PM

Subject: [Eppnicbr] RES: RES: RES: RES: RES: RES: Acesso TLS

 

Olá, estou tentando implementar na plataforma .net, alguém pode me passar
algumas dicas para a comunicação, etou tentando fazer através e socket, se
alguem conhece outro jeito de conectar e se tiver a boa vontade de me avisar
ficarei grato!

 

Atenciosamente,


Felipe Rodrigues Pereira
Sistemas

Tecla Serviços de Internet


----------------------------------------------------------------------------
---------


Tel.: (11) 3524-4339
 <http://www.tecla.com.br> www.tecla.com.br

Serviços de Internet 

 


  _____  


_______________________________________________
eppnicbr mailing list
eppnicbr at eng.registro.br
https://eng.registro.br/mailman/listinfo/eppnicbr

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://eng.registro.br/pipermail/eppnicbr/attachments/20080409/3c0f3eb0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1673 bytes
Desc: not available
URL: <http://eng.registro.br/pipermail/eppnicbr/attachments/20080409/3c0f3eb0/attachment.gif>


More information about the eppnicbr mailing list