Results 1 to 1 of 1

Thread: SSL Connection

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2006
    Posts
    1

    SSL Connection

    Hi,

    I hope someone can help me with this problem. I am rather new to https and i am trying to program a local client which connects to a server and downloads zip files. So far i have written the following code based on resources which i have found on the net but it does not work.

    VB Code:
    1. Dim callback As New RemoteCertificateValidationCallback(AddressOf OnCertificateValidation)
    2.             lFileStream = New FileStream(Filename, FileMode.Create)
    3.             Stream = New SslStream(lFileStream, False, callback)
    4.             Stream.AuthenticateAsClient(server)
    5.             If Stream.IsAuthenticated Then
    6.                 ' Indicates whether the authentication was successful.
    7.                 Console.WriteLine("IsAuthenticated: {0}", Stream.IsAuthenticated)
    8.                 ' Indicates whether both the client and server has been authenticated.
    9.                 ' In this example only the server is authenticated.
    10.                 Console.WriteLine("IsMutuallyAuthenticated: {0}", Stream.IsMutuallyAuthenticated)
    11.                 ' Indicates whether the SslStream uses data encryption.
    12.                 Console.WriteLine("IsEncrypted: {0}", Stream.IsEncrypted)
    13.                 ' Indicates whether the data sent is signed.
    14.                 Console.WriteLine("IsSigned: {0}", Stream.IsSigned)
    15.                 ' Indicates whether the current side of the connection is authenticated as a server.
    16.                 Console.WriteLine("IsServer: {0}", Stream.IsServer)
    17.             End If
    18.             lHttpWebRequest = CType(WebRequest.Create(sURL), HttpWebRequest)
    19.             lHttpWebResponse = CType(lHttpWebRequest.GetResponse, HttpWebResponse)
    20.             lHttpWebResponseStream = lHttpWebRequest.GetResponse.GetResponseStream
    21.             pProgress.Value = 0
    22.             pProgress.Maximum = CType(lHttpWebResponse.ContentLength, Integer)
    23.             Do
    24.                 bytesRead = lHttpWebResponseStream.Read(byteBuffer, 0, 1000)
    25.                 lFileStream.Write(byteBuffer, 0, bytesRead)

    Can anyone help we realise what is wrong and how i can correct this? I keep getting an error that says the connection is closed.

    regards,

    Jesper
    Last edited by si_the_geek; Nov 29th, 2006 at 09:55 AM. Reason: added vbcode tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width