Simple-HTTPS-server - WeOnlyDo Software example code



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 HTTPS server
VB code
Dim WithEvents wodWebServer1 As wodWebServerCom
Private Sub Form_Load()
    Set wodWebServer1 = New wodWebServerCom
    Dim cert As New Certificate
   
    'Using wodCertificate we will load private key and certificate inside wodWebServer.
    'This is needed to start HTTPS (HTTP+SSL) server.
    cert.Load "c:\cert.pem" 'load certificate inside wodCertificate
    cert.LoadKey "c:\cert.key" 'load private key inside wodCertificate
   
    'Connect wodCertificate object with wodWebServer.
    Set wodWebServer1.Certificate = cert
   
    'Select SSL protocol inside Secure Property.
    wodWebServer1.Secure = ProtSSL23
    wodWebServer1.DocumentRoot = App.Path
   
    wodWebServer1.Start 'start a web server
End Sub
VB.NET code
Dim WithEvents wodWebServer1 As WeOnlyDo.Server.WebServer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    wodWebServer1 = New WeOnlyDo.Server.WebServer

    'First we need to load some certificate which is needed for HTTPS(HTTP+SSL) server.
    Dim cert As New System.Security.Cryptography.X509Certificates.X509Certificate2
    cert.Import("c:\certificate.pfx", "weonlydo", Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable)

    'Connect certificate object with wodWebServer.NET.
    wodWebServer1.Certificate = cert

    'Select SSL Protocol.
    wodWebServer1.Secure = True
    wodWebServer1.DefaultPage = "index.html" 'Specify default page file
    wodWebServer1.DocumentRoot = "C:\Web"

    wodWebServer1.Start() 'Start a web server
End Sub
C# code
WeOnlyDo.Server.WebServer wodWebServer1;
private void Form1_Load(object sender, EventArgs e)
{
    wodWebServer1 = new WeOnlyDo.Server.WebServer();

    //First we need to load some certificate which is needed for HTTPS(HTTP+SSL) server.
    System.Security.Cryptography.X509Certificates.X509Certificate2 cert = new System.Security.Cryptography.X509Certificates.X509Certificate2();
    cert.Import("c:\\certificate.pfx", "weonlydo", System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable);

    //Connect certificate object with wodWebServer.NET.
    wodWebServer1.Certificate = cert;

    //Select SSL Protocol.
    wodWebServer1.Secure = true;
    wodWebServer1.DefaultPage = "index.html"; //Specify default page file
    wodWebServer1.DocumentRoot = "C:\\Web";

    wodWebServer1.Start(); //Start a web server.
}