NetBurner 3.5.0
PDF Version
 
HTTPS WebSocket Demo

SSL/TLS Websocket example program with web page redirection for unauthorized access. The example demonstrates how you can have both secure and non-secure access to files and directories, alongside secure and non-secure access to WebSockets.

The application starts the web server with SSL/TLS capability. The directory structure is such that index.html, script.js, and the files in the images subdirectory can be viewed with a http or https connection. However, files in the httpsdir directory (ie ssl.html) can only be viewed with a secure https connection.

  html
  |-- httpsdir
        |-- ssl.html
  |-- images
        |-- (various image files)
  |-- index.html
  |-- script.js

The HTTP_ACCESS CheckHttpAccess(int sock, int access_level, HTTP_Request &Req) function is used to authenticate the web page access. It will allow access or redirect depending on the file and access rights.

The StartHttps() function starts the webserver for both HTTP and WebSockets. If SSL-only access is desired, StartHttps(443, 0) can be used instead.