Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

Reading SSLStream

$
0
0
Currently I have some code which looks like this:
Code:

    Public Function connect(ByVal ip As String, ByVal port As Integer, ByVal type As type)
        client.Connect(ip, port)
        networkStream = New SslStream(client.GetStream, False, New RemoteCertificateValidationCallback(AddressOf TrustAllCertificatesCallback))

        If type = SMTP.type.TLS Then
            Dim clearTextReader = New StreamReader(client.GetStream())
            Dim clearTextWriter = New StreamWriter(client.GetStream()) With {.AutoFlush = True}

            Debug.WriteLine(clearTextReader.ReadLine())
            clearTextWriter.WriteLine("HELO")
            Debug.WriteLine(clearTextReader.ReadLine())
            clearTextWriter.WriteLine("STARTTLS")
            Debug.WriteLine(clearTextReader.ReadLine())

            networkStream.AuthenticateAsClient(ip)
            SendText("HELO")
            getResponse()
        Else
            networkStream.AuthenticateAsClient(ip)
            getResponse()
            SendText("HELO")
            getResponse()
        End If

        Return Nothing

    End Function

My getResponse code looks like:
Code:

Dim bytes() As Byte
        ReDim bytes(client.ReceiveBufferSize)
        networkStream.Read(bytes, 0, CInt(client.ReceiveBufferSize))
        Debug.WriteLine(Encoding.ASCII.GetString(bytes))

Everytime I hit the networkStream.Read line, it stops dead in its track. What could be the problem?

Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>