HShbib
HShbib

Reputation: 1841

How do you use HTTPS and SSL on 'localhost'?

I would like to know how to set up SSL on my web application on the localhost.

I don't have any background in doing this and would appreciate guidance. I already finished implementing my web application and i need it to use HTTPS on the localhost or while I host it on a server.

Any ideas?

Upvotes: 102

Views: 162276

Answers (3)

brianyang
brianyang

Reputation: 1140

I came across this page when I was looking for the easiest and quickest way to do this. Using Webpack is much simpler:

install webpack-dev-server

npm i -g webpack-dev-server

start webpack-dev-server with https

webpack-dev-server --https

Upvotes: 11

Jason Williams
Jason Williams

Reputation: 2860

It is easy to create a self-signed certificate, import it, and bind it to your website.

1.) Create a self-signed certificate:

Run the following 4 commands, one at a time, from an elevated Command Prompt:

cd C:\Program Files (x86)\Windows Kits\8.1\bin\x64

makecert -r -n "CN=localhost" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -sv localhost.pvk localhost.cer

cert2spc localhost.cer localhost.spc

pvk2pfx -pvk localhost.pvk -spc localhost.spc -pfx localhost.pfx

2.) Import certificate to Trusted Root Certification Authorities store:

Start → runmmc.exeCertificates plugin"Trusted Root Certification Authorities"Certificates

Right-click CertificatesAll Tasks → *Import. Find your "localhost" Certificate at C:\Program Files (x86)\Windows Kits\8.1\bin\x64\

3.) Bind certificate to website:

Start → (IIS) ManagerClick on your Server → click on Sites → Click on your top level site → Bindings.

Add or edit a binding for https and select the SSL certificate called "localhost".

4.) Import Certificate to Chrome:

Chrome SettingsManage Certificates → Import .pfx certificate from the *C:\certificates* folder.

Test Certificate by opening Chrome and navigating to https://localhost/

Upvotes: 26

JackArbiter
JackArbiter

Reputation: 5795

If you have IIS Express (with Visual Studio):

To enable the SSL within IIS Express, you have to just set “SSL Enabled = true” in the project properties window.

See the steps and pictures at this code project.

IIS Express will generate a certificate for you (you'll be prompted for it, etc.). Note that depending on configuration the site may still automatically start with the URL rather than the SSL URL. You can see the SSL URL - note the port number and replace it in your browser address bar, you should be able to get in and test.

From there you can right click on your project, click property pages, then start options and assign the start URL - put the new https with the new port (usually 44301 - notice the similarity to port 443) and your project will start correctly from then on.

enter image description here

Upvotes: 29

Related Questions