Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Vb 2005 ftp ssl

I wrote a small ftp program to transfer a file FTP.
I want to use FTP over SSL, but when I enable the SSL property, I still get connection errors. My connection script worked fine as ftp, but I'm not sure if I have to exchange a certificate now, or if it should be automatic?

Anyone know where i can find some sample code for this??

Thanks :confused:

..I can submit the code, and i dont care what i connnect to for testing as long as its ssl-ftp.
[483 byte] By [Jamesxyz1234] at [2007-11-11 10:06:38]
# 1 Re: Vb 2005 ftp ssl
Can you submit the code?
waterjock2000 at 2007-11-11 20:48:33 >
# 2 Re: Vb 2005 ftp ssl
Imports System.Net
Imports System.IO
Imports System.Security.Cryptography.X509Certificates
'System.Net.FtpWebRequest.EnableSsl

Public Class Form1

Private Sub Uploader1(ByVal source As String, ByVal target As String, _
ByVal credential As NetworkCredential)
Dim request As FtpWebRequest = _
DirectCast(WebRequest.Create(target), FtpWebRequest)
Dim tempCert As X509CertificateCollection

request.Method = WebRequestMethods.Ftp.UploadFile
request.Credentials = credential
request.EnableSsl = True '***********************

tempCert = request.ClientCertificates
request.ClientCertificates = tempCert

Dim reader As New FileStream(source, FileMode.Open)
Dim buffer(Convert.ToInt32(reader.Length - 1)) As Byte
reader.Read(buffer, 0, buffer.Length)
reader.Close()
request.ContentLength = buffer.Length
Dim stream As Stream = request.GetRequestStream
stream.Write(buffer, 0, buffer.Length)
stream.Close()
Dim response As FtpWebResponse = DirectCast(request.GetResponse, FtpWebResponse)

MsgBox((response.ExitMessage))
response.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim credential As New NetworkCredential("test", "test")
Uploader1("c:\text1.txt", "ftp://put server here/text1.txt", credential)

End Sub
End Class
Jamesxyz1234 at 2007-11-11 20:49:38 >
# 3 Re: Vb 2005 ftp ssl
anyone? :WAVE:
Jamesxyz1234 at 2007-11-11 20:50:37 >
# 4 Re: Vb 2005 ftp ssl
Try this:
http://pjondevelopment.50webs.com/files/FTPLibrary.zip

Found it using google codesearch:
http://www.google.com/codesearch?hl=en&lr=&q=lang%3Abasic+ftp+ssl
waterjock2000 at 2007-11-11 20:51:38 >
# 5 Re: Vb 2005 ftp ssl
i looked at the zip. It doesnt look like they are exchanging any certificates. Anyone know of a simple sftp program i can test it on? Maybe the one i was using was the problem.
Jamesxyz1234 at 2007-11-11 20:52:37 >
# 6 Re: Vb 2005 ftp ssl
The first one that comes to mind is ipswitch WS_FTP (there is an eval)

http://www.ipswitch.com/products/ws_ftp/index.asp?t=features
waterjock2000 at 2007-11-11 20:53:36 >
# 7 Re: Vb 2005 ftp ssl
thats actually the one i was having trouble with. Probly somthing ive overlooked. Ill try again.
Thanks.
Jamesxyz1234 at 2007-11-11 20:54:45 >