Layout
Layout
Layout
Layout
Layout
VSCode Customization

VSCode - Set up https for vscode live preview

https security protocol setup with private key and certificate

Introduction

Vscode live preview default protocol is http. To setup https protocol to have secure transmission of data and header, you can try the following procedure. This instruction is for Apple Mac and Linux.

Setup

1. Create a private key

Using terminal application, change the current directory to a directory where the private key to be kept. A password will be required to open the file and to use it. This requires openssl software installed. This will create an output file localhost.key (can be named anything, with .key extension).

private key creation

2. Create the Certificate

This will create output localhost.pem (can be named anything, with .pem extension). Answer the question prompts that are asked while executing the command.

certificate creation

3. Setup .vscode settings json file

a. Create a .vscode directory

Create a .vscode directory folder in the project root folder. This will contain the settings json file created with settings info.

b. Create a "settings.json" file

create a json file inside the .vscode folder

c. Settings.json content

Add the following json conent to the settings.json file. the location of the certificate and key files are to be modified to address user stored location. Also, modify the passphrase/password used while creating the files.

JSON
Copy
{
    "liveServer.settings.port":5501,
    "liveServer.settings.root":"/",
    "liveServer.settings.CustomBrowser":"chrome",
    "liveServer.settings.https":{
          "enable":true,
          "cert":"/Users/user1/folder/location/of/the/key/certificate/files/https/localhost.pem",
          "key":"/Users/user1/folder/location/of/the/key/certificate/files/https/localhost.key",
          "passphrase":"usersownpassword"
    }
}