httpsys icon indicating copy to clipboard operation
httpsys copied to clipboard

How to make HTTPS work

Open rodrigopolo opened this issue 12 years ago • 0 comments

Instructions to make the example work on HTTPS

Everything should be done on Command Prompt or PowerShell as an administrator

  1. Set the path for makecert
SET PATH=%PATH%;C:\Program Files (x86)\Windows Kits\8.0\bin\x64\
  1. Create a self-signed X.509 certificate
makecert -sr LocalMachine -ss My -pe -n "CN=mydomain.me" -a sha256 -len 1024 -r
  1. Locate certificate and get the certhash.

    • Run "mmc" as an administrator.
    • Click on "file" menu, then select on the list of "Available snap-ins" the "Certificates" and press the button "Add".
    • Select "Computer account" on the new window and click on the "next" button.
    • Select "Local computer" and click the "Finish" button.
    • Clic on the "Ok" button.
    • Go to the "Console Root->"Certificates (Local Computer)">-"Personal"->"Certificates" folder.
    • Double click on the certificate you just created (CN=mydomain.com)
    • Click on "Details" tab
    • Scroll to see the thumbprint select and copy
  2. Register this certificate to be used by HTTP.SYS for all connections made on the TCP port on which you intend to set up the HTTPS server, remove white spaces from the thumbprint you just copied, BTW it is case sensitive, leve it as it is, just remove the white spaces, the appid parameter is an arbitrary GUID.

    netsh http add sslcert ipport=0.0.0.0:8080 certhash=73abd3c3ac5fd7ff867fe6255207fa1528cee7a1 appid={00112233-4455-6677-8899-AABBCCDDEEFE}
    
  3. Verify the certificate is properly installed

    netsh http show sslcert ipport=0.0.0.0:8080
    
  4. Finally, author your HTTPS server:

    require('httpsys').slipstream(); 
    
    var https = require('https');
    var options = {};
    
    https.createServer(options, function (req, res) {
     res.writeHead(200, { 'Content-Type': 'text/plain' });
     res.end('Hello, world!');
    }).listen(8080);
    

rodrigopolo avatar Aug 16 '13 08:08 rodrigopolo