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:
Dim callback As New RemoteCertificateValidationCallback(AddressOf OnCertificateValidation) lFileStream = New FileStream(Filename, FileMode.Create) Stream = New SslStream(lFileStream, False, callback) Stream.AuthenticateAsClient(server) If Stream.IsAuthenticated Then ' Indicates whether the authentication was successful. Console.WriteLine("IsAuthenticated: {0}", Stream.IsAuthenticated) ' Indicates whether both the client and server has been authenticated. ' In this example only the server is authenticated. Console.WriteLine("IsMutuallyAuthenticated: {0}", Stream.IsMutuallyAuthenticated) ' Indicates whether the SslStream uses data encryption. Console.WriteLine("IsEncrypted: {0}", Stream.IsEncrypted) ' Indicates whether the data sent is signed. Console.WriteLine("IsSigned: {0}", Stream.IsSigned) ' Indicates whether the current side of the connection is authenticated as a server. Console.WriteLine("IsServer: {0}", Stream.IsServer) End If lHttpWebRequest = CType(WebRequest.Create(sURL), HttpWebRequest) lHttpWebResponse = CType(lHttpWebRequest.GetResponse, HttpWebResponse) lHttpWebResponseStream = lHttpWebRequest.GetResponse.GetResponseStream pProgress.Value = 0 pProgress.Maximum = CType(lHttpWebResponse.ContentLength, Integer) Do bytesRead = lHttpWebResponseStream.Read(byteBuffer, 0, 1000) 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


Reply With Quote