All wodCrypt (12) wodSSH (10) wodSFTP (23) wodSSHServer (1) wodSSHTunnel (11) wodSSHpackage wodSFTPdll wodSSH.NET (10) wodSFTP.NET (24) wodFtpDLX.NET (22) wodWebServer.NET (10) wodAppUpdate (13) wodHttpDLX (8) wodFtpDLX (22) wodTelnetDLX wodFTPServer (3) wodWebServer (10) wodVPN wodXMPP (13) | All ** [Visual Basic] ** [C#] ** [VB.NET] ** Simple FTPS Server
VB code
Public WithEvents FtpD As wodFTPDCom Public cert As Certificate Private Sub Form_Load() ' Initialize instance of wodFtpServer Set FtpD = New wodFTPDCom ' Initialize wodCertificate object Set cert = New Certificate End Sub Private Sub Command1_Click() ' Generate the needed Certificate and Private key cert.GenerateKey RSAKey cert.CommonName = "your.host.com" cert.Country = "US" cert.Email = "me@host.com" cert.FriendlyName = "my cert" cert.Locality = "US" cert.Organization = "My org" cert.State = "US" cert.ValidTo = Now + 365 '1 year cert.Generate 'RSAkey cert.Show ("This is your certificate") Set FtpD.Certificate = cert ' Let's specify FTPS protocol FtpD.Protocol = FTPS ' If not specified otherwise, wodFtpServer will listen on default protocol port (21 for FTPS) FtpD.Port = 21 ' Start listening for connections. FtpD.Start End Sub Private Sub Command2_Click() ' Let's stop the server FtpD.Stop End Sub Private Sub FtpD_LoginPassword(ByVal User As wodFTPDComLib.FtpUser, ByVal Login As String, ByVal Password As String, ByRef Action As wodFTPDComLib.FtpActions) ' Accept all users, and assign default directory Action = Allow User.HomeDir = "c:\" End Sub VB.Net code
Public WithEvents FtpD As wodFTPDComLib.wodFTPDCom Public cert As WODCERTMNGLib.Certificate Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Initialize instance of wodFtpServer FtpD = New wodFTPDComLib.wodFTPDCom ' Initialize wodCertificate object cert = New WODCERTMNGLib.Certificate End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Generate the needed Certificate and Private key cert.GenerateKey(0) cert.CommonName = "your.host.com" cert.Country = "US" cert.Email = "me@host.com" cert.FriendlyName = "my cert" cert.Locality = "US" cert.Organization = "My org" cert.State = "US" cert.ValidTo = Now.AddYears(1) '1 year cert.Generate() cert.Show("This is your certificate") FtpD.Certificate = cert ' Let's specify FTPS protocol FtpD.Protocol = wodFTPDComLib.ProtocolsEnum.FTPS ' If not specified otherwise, wodFtpServer will listen on default protocol port (21 for FTPS) FtpD.Port = 21 ' Start listening for connections. FtpD.Start() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Let's stop the server FtpD.Stop() End Sub Private Sub FtpD_LoginPassword(ByVal User As wodFTPDComLib.FtpUser, ByVal Login As String, ByVal Password As String, ByRef Action As wodFTPDComLib.FtpActions) Handles FtpD.LoginPassword 'Accept all users, and assign default directory Action = wodFTPDComLib.FtpActions.Allow User.HomeDir = "c:\" End Sub C# code
private wodFTPDComLib.wodFTPDCom FtpD; private WODCERTMNGLib.Certificate cert; private void button1_Click(object sender, EventArgs e) { // Generate the needed Certificate and Private key cert.GenerateKey(0); cert.CommonName = "your.host.com"; cert.Country = "US"; cert.Email = "me@host.com"; cert.FriendlyName = "my cert"; cert.Locality = "US"; cert.Organization = "My org"; cert.State = "US"; cert.ValidTo = DateTime.Now.AddYears(1); //1 year cert.Generate(); cert.Show("This is your certificate", this); FtpD.Certificate = cert; // Let's specify FTPS protocol FtpD.Protocol = wodFTPDComLib.ProtocolsEnum.FTPS; // If not specified otherwise, wodFtpServer will listen on default protocol port (21 for FTPS) FtpD.Port = 21; // Start listening for connections. FtpD.Start(FtpD.Port); } void FtpD_LoginPassword(wodFTPDComLib.FtpUser User, string Login, string Password, ref wodFTPDComLib.FtpActions Action) { // Accept all users, and assign default directory Action = wodFTPDComLib.FtpActions.Allow; User.HomeDir = "c:\\"; } private void Form1_Load(object sender, EventArgs e) { // Initialize instance of wodFtpServer FtpD = new wodFTPDComLib.wodFTPDCom(); // Initialize the Certificate object cert = new WODCERTMNGLib.Certificate(); FtpD.LoginPassword += new wodFTPDComLib._IwodFTPDComEvents_LoginPasswordEventHandler(FtpD_LoginPassword); } private void button2_Click(object sender, EventArgs e) { //Let's stop the server FtpD.Stop(); } |