Question Connect to EPP Server using x.509 Certificate?

digitaldrew

Well-known member
Joined
Nov 10, 2012
Messages
145
Programming Experience
Beginner
Hey everyone. I need to connect to an EPP server using TCP/SSL, and also pass an x.509 certificate which is required to establish an authenticated and encrypted communications channel between my software and the registry.

I've got no problems connecting with TCPStream and SSLStream as you can see in my code below. However, I've never done this with an x.509 certificate before. These are usually required for domains/websites on Linux servers to make them safer for shoppers, aren't they? With that in mind, my first question would be whether or not this is even possible through VB.net?

According to the registry, I will need the following:
cert.pem is the public key (my x.509 certificate). It must be obtained from an accepted Certificate Authority.
key.pem - my private key. Used to create a digital signature that is verifiable by anyone with the public key.
cacert.pem - The Root Certificate for the Certificate Authority that signed your certificate.

I know where to get the certificate and can buy that no problem. But, I don't really want to buy one if this can't be done through .NET..

Below is some of the code I currently use when connecting with TCPStream/SSLstream. As I said, this works just fine until I try to connect with a registry that requires x.509 certificates (like the one I am working with now). Any idea how I would change this around to use the x.509 certificate once I purchase one? They have mentioned openssl when I previously spoke to them, but I'm not too familiar with that.

Code:
        Dim requestResponse As String = String.Empty
        Dim client As New TcpClient(DRShost, 700)
        Dim sslStream As New Security.SslStream(client.GetStream(), True)
        sslStream.AuthenticateAsClient(DRShost)

        Try
            Dim greeting As String = GetResponse(sslStream, System.Text.Encoding.UTF8)
            Dim loginElement As XElement
            loginElement = someXMLhere
            SendRequest(loginElement.ToString, sslStream, System.Text.Encoding.UTF8)
            requestResponse = GetResponse(sslStream, System.Text.Encoding.UTF8)

            If requestResponse.Contains("Command completed successfully") = False Then
                Handle Errors
Else
                Success
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
       End Try
Thanks for any input/help I can receive!!
 
Top Bottom