I found the certificate in File Zilla. I put the following in the dim line. and I still get a path alarm.
Dim cert As X509Certificate = X509Certificate.CreateFromCertFile("C:\Users\Dave\AppData\Roaming\FileZilla\trustedcerts.xml")
System.Security.Cryptography.CryptographicException
HResult=0x80070003
Message=The system cannot find the path specified.
Source=mscorlib
StackTrace:
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile(String filename)
at MfgControl.AdvancedHMI.MainForm.FtpRead_Tomorrow() in C:\AERO3\V399yBeta\AdvancedHMI\MainForm2.vb:line 130
at MfgControl.AdvancedHMI.MainForm.Timer2_Tick(Object sender, EventArgs e) in C:\AERO3\V399yBeta\AdvancedHMI\MainForm2.vb:line 213
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at MfgControl.AdvancedHMI.My.MyApplication.Main(String[] Args) in :line 81
I tried it your way too, same result. The following is the entire routine.
Private Sub FtpRead_Tomorrow()
'GET TODAYS DIRECTORY
'LOAD EPICOR DATA
' Get the object used to communicate with the server.
Dim request As Net.FtpWebRequest = DirectCast(WebRequest.Create(FtpAddress & "/*.*"), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
'THE FOLLOWING 5 LINES WILL NEED TO BE TURNED ON IF CERTIFICATES ARE REQUIRED
request.EnableSsl = True
Dim cert As X509Certificate = X509Certificate.CreateFromCertFile("C:\MyCertificates\Cert1.cer")
Dim certCollection As X509CertificateCollection = New X509CertificateCollection()
certCollection.Add(cert)
request.ClientCertificates = certCollection
' This example assumes the FTP site uses anonymous logon.
request.Credentials = New NetworkCredential(FtpUserName, FtpPassword)
Using response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
Dim responseStream As IO.Stream = response.GetResponseStream()
Using reader As New IO.StreamReader(responseStream)
RichTextBox1.Text = (reader.ReadToEnd())
End Using
End Using
Thanks,
Dave