This project is read-only.

Help with connecting with Certificate

Nov 19, 2015 at 7:54 PM
Edited Nov 19, 2015 at 11:32 PM
Can someone provide me with a sample of how to connect with an X509Certificate?

Here is what I am currently doing but getting errors when I try to connect:
System.Net.Sockets.SocketException was caught
  Message=An attempt was made to access a socket in a way forbidden by its access permissions 151.151.65.207:21
  Source=System
  ErrorCode=10013
  NativeErrorCode=10013
                X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

                store.Open(OpenFlags.ReadOnly);
                X509Certificate x509Cert = null;
                foreach (X509Certificate2 mCert in store.Certificates)
                {
                    if(mCert.FriendlyName.Contains("WF CA P12 Individual Certificate"))
                    {
                        x509Cert = mCert;
                        break;
                    }
                    
                }



                using (FTPSClient client = new FTPSClient())
                {
                   
                    string message = client.Connect(strServerAddress, 
                                    intPortNumber,
                                   new NetworkCredential(strUserName,
                                                         strPassword),
                                    ESSLSupportMode.Implicit,
                                    null,
                                    x509Cert, 0, 0, 0, null); 

                    // upload a file
                    client.PutFile(@pathFileNameWithExtension, @FTPFileNameWithExtension);

                    client.Close();

                    if (message == "")
                    {
                        errMessage = String.Format("Upload of {0} to {1} failed with the message {2}.", pathFileNameWithExtension, strServerAddress, message);
                        haveError = false;
                    }

                }