[Eppnicbr] Problema com conexão epp e ssl

Felipe Rodrigues Pereira felipe.pereira at tecla.com.br
Thu Apr 10 11:44:11 BRT 2008


Pessoa estou com o seguinte problema, estou usando uma classe em c# para
comunicação com o servidor epp, 

 

Tentei converter os certificados client.pem e root.pem para client.der e
root.der, segundo instruções de uma amigo da lista, 

 

Os certificados ficaram com caracter estranhos fora do padrão que é :

 

---BEGIN CERTIFICATE-----

MIID7DCCAtSgAwIBAgIBBTANBgkqhkiG9w0BAQQFADCBjzELMAkGA1UEBhMCQlIx

wtv0dCpo++UW/HHUqOeHn40AjJKJGo8QS9GHWJEAObwmEcEhAs5x0KNS1YTe3boD

WpB//fY919Iz8F5g4CLsBU/diJ74wrzJ7UhMfGdnMr1hcXQUSG1f+QDUYR1mwCKK

qSUt58JLqH/kFGI+HM0p6SritSMg0RSsaQfTZ0rf9kBmiSymb7M5zJd3eYwyJu3l

-----END CERTIFICATE-----

 

 

Não sei se por isso não estou conseguindo rodar a classe de comunicação a
classe é esta:

Se alguem puder me ajudar fico grato! Ou me adicionar no MSN para me dar
algumas dicas lipe_hc1 at hotmail.com. Obrigado!

 

 

 

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;

using System.Security.Authentication;

 

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("C:\\_tecla\\Projetos\\RegistroBrasil\\ce
rtificados\\client.der");

        X509Certificate x5091 =
X509Certificate.CreateFromCertFile("C:\\_tecla\\Projetos\\RegistroBrasil\\ce
rtificados\\root.der");

        X509CertificateCollection certs = new X509CertificateCollection();

 

        certs.Add(x509);

        certs.Add(x5091);

 

ß---- O erro ocorre na linha de baixo !!!! ERRO: “ Falha a uma chamada a
SSPI, consulte a exceção interna.” -----à

 

        sslStream.AuthenticateAsClient("beta.registro.br:700", certs,
SslProtocols.Tls, false);      

 

      ß---- Fim do ERRO -----à

 

 

        byte[] bytes = new byte[1024];

 

        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;

    }

 

}

 

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

 

    {

            

        EppSSL epp = new EppSSL();

        epp.run();

    }

}

 

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 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://eng.registro.br/pipermail/eppnicbr/attachments/20080410/bf476aea/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/20080410/bf476aea/attachment.gif>


More information about the eppnicbr mailing list