2 Replies - 240 Views - Last Post: 27 November 2017 - 02:02 PM Rate Topic: -----

#1 peugeottech  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-November 17

Sslstream issue

Posted 27 November 2017 - 03:46 AM

Hi Guys,

Im very new to vb.net and have a issue with connecting to a server using a tls connection as I would like to make a small ftp programe

I am aware there are many .net libraries for this out there but I wanted to learn it for myself

The socket seems to connect fine but I get a error on the "sslStream.AuthenticateAsClient"
"The handshake failed due to an unexpected packet form"


here is my code so far

Public Sub ConnectToFtp()

        Dim Sock As New TcpClient
        Dim clientCertificatecollection As New X509CertificateCollection

        
        Dim HostName As String = "SomeHost"
        Dim PortNumber As Integer = 1234

        Sock.Connect(HostName, PortNumber)
        

         Dim sslStream = New SslStream(Sock.GetStream(), False, New RemoteCertificateValidationCallback(AddressOf 
         ValidateServerCertificate), Nothing)
       

         
        sslStream.AuthenticateAsClient(HostName, clientCertificatecollection, Security.Authentication.SslProtocols.Tls11, True)
        


    End Sub

    Public Shared Function ValidateServerCertificate(sender As Object, certificate As X509Certificate, chain As X509Chain, 
    sslPolicyErrors__1 As SslPolicyErrors) As Boolean
    Return True
    End Function





many thanks for your time

Is This A Good Question/Topic? 0
  • +

Replies To: Sslstream issue

#2 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6541
  • View blog
  • Posts: 26,483
  • Joined: 12-December 12

Re: Sslstream issue

Posted 27 November 2017 - 12:36 PM

I know nothing about this but searching "sslStream.AuthenticateAsClient the handshake failed" I get the impression it is something to do with port numbers.
Was This Post Helpful? 0
  • +
  • -

#3 peugeottech  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-November 17

Re: Sslstream issue

Posted 27 November 2017 - 02:02 PM

Thanks for the reply , I have made a few more ftp sites with other ports and have the same issue

I have changed the sslprotocols and still have the same error
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1