Jump to content

HTTPS WebServer Using Stunnel


andybiochem
 Share

Recommended Posts

Hi all,

It has been a long time since I posted here, but I thought I might share a few things.

First topic is setting up a webserver to use https.

This assumes you already have a working autoit http webserver. If not, the code below will server up a simple "hello world" response:

 

;----- Start TCP & Listen -----
TCPStartup()
Global $iMainSocket = TCPListen("127.0.0.1", 80)
Global $iNewSocket

;----- HTML Reply -----
Global $sHTML = "Hello, world!"

;########## LOOP ##########
While 1

    ;----- SLEEP -----
    Sleep(100)

    ;----- Accept New Connection -----
    $iNewSocket = TCPAccept($iMainSocket)
    If @error Then ContinueLoop

    ;----- Check if Client Wants Something -----
    TCPRecv($iNewSocket, 1024)
    If @error Then ContinueLoop

    ;----- Send Back HTML -----
    TCPSend($iNewSocket, Binary($sHTML & @CRLF & @CRLF))

    ;----- Drop Socket -----
    TCPCloseSocket($iNewSocket)

WEnd
;########## END LOOP ##########

 

Note that it is important that the autoit server is listening on 127.0.0.1 as in the code above - this is the IP address stunnel will be sending received https data to.

Install stunnel

Stunnel will automatically generate a self-signed certificate.

Replace the stunnel configuration file with this:

[https]
accept  = 443
connect = 80
cert = stunnel.pem
TIMEOUTclose = 0

 

Make sure both stunnel and your webserver are running, and you should be able to connect to the webserver using https.

 

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...