score:1
use something like root ssl certificate
generate a key
openssl genrsa -des3 -out rootca.key 2048
with they key you can generate a certificate which is good for 1,024 days
openssl req -x509 -new -nodes -key rootca.key -sha256 -days 1024 -out rootca.pem
open keychain access on your mac and go to the certificates category and emport that rootca.pem generated from the last step. double click and under "when using this certiciate" select 'always trust'
create an openssl configuration file
server.csr.cnf
[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
[dn]
c=us
st=randomstate
l=randomcity
o=randomorganization
ou=randomorganizationunit
emailaddress=hello@example.com
cn = localhost
create a v3.ext file to create a x509 v3 certificate.
authoritykeyidentifier=keyid,issuer
basicconstraints=ca:false
keyusage = digitalsignature, nonrepudiation, keyencipherment, dataencipherment
subjectaltname = @alt_names
[alt_names]
dns.1 = localhost
create a certificate key for localhost using the configuration settings stored in server.csr.cnf. this key is stored in server.key.
openssl req -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout server.key -config <( cat server.csr.cnf )
a certificate signing request is issued via the root ssl certificate we created earlier to create a domain certificate for localhost. the output is a certificate file called server.crt.
openssl x509 -req -in server.csr -ca rootca.pem -cakey rootca.key -cacreateserial -out server.crt -days 500 -sha256 -extfile v3.ext
you’re now ready to secure your localhost with https. move the server.key and server.crt files to an accessible location on your server and include them when starting your server.
in an express app written in node.js, here’s how you would do it. make sure you do this only for your local environment. do not use this in production.
var path = require('path')
var fs = require('fs')
var express = require('express')
var https = require('https')
var certoptions = {
key: fs.readfilesync(path.resolve('build/cert/server.key')),
cert: fs.readfilesync(path.resolve('build/cert/server.crt'))
}
var app = express()
var server = https.createserver(certoptions, app).listen(443)
check https://github.com/dakshshah96/local-cert-generator/ for more detailed instructions
Source: stackoverflow.com
Related Query
- Starting a react app in HTTPS instead of HTTP
- Heroku redirect Next.js React client app http to https
- Why does my HTTP GET call to a subroute in react app gives a 404 NOT Found instead of HTML?
- TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app
- React app error: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS
- Why cannot I redirect my React app on Heroku from http to https?
- Cant load a react app after starting server
- React App not starting in azure app service
- Starting React App from pulled github project
- docker-compose stops immediately after starting react app created using create-react-app
- My React app is using values from the .env file instead of the .env.local file
- isomorphic/universally-rendered React 15 app breaks with Cloudflare HTTP Proxy ("orange cloud")
- error when starting react app
- HTTP POST request with JSON payload from react app returns net::ERR_SSL_PROTOCOL_ERROR(chrome)
- Why Electron is building react app with previous changes instead of latest ones?
- why vscode open react app in edge instead of chrome?
- React App loads HomePage instead of Desired Page
- External link in react is being appended with localhost if no http or https present
- How to load react app at say localhost:3000/home instead of localhost:3000?
- API calls served over HTTP instead of HTTPs results in error in React/Axios
- facing fs-extra, html-webpack-plugin-before-html-processing, graceful-js issues when starting react app
- How to fix "Response to preflight request doesn't pass access control check: It does not have HTTP ok status" error in react app with nodejs api
- Http 404 on Azure Websites for react app
- Why Firebase deploy's full react app instead of deploying build directory files?
- React app injecting into js instead of index.html
- fetch is told to call an http resource, but it calls an https one instead
- Why the compiler looks for dependencies packages on src folder instead of node_modules folder in a React app running on Ubuntu
- http proxy middleware is not created proxies in my react app
- React app with wordrpess on nginx won't work on HTTPS
- HTTP GET response 304 status error after deploying react app on netlify
More Query from same tag
- Passing data target as a prop
- Redux middleware returning callbacks not state object
- Checkbox selected for delete several reconds in React app
- Getting Redux Reducer to Merge Arrays
- Implement a feature in my React app where the users can add my products to their Shopify store
- how to import multiple components as a single component and use them in lazy load
- Redirecting to path shows : TypeError: Cannot read property 'pathname' of undefined
- Floating Action Button: Is there a straightforward way to make a button smaller than default mini?
- Cannot read property 'map' of undefined [React.js]
- Click events are not available on the map of the react
- How can I apply styling to Material UI tabs in React?
- @react-google-maps/api / Feature click event resets state
- How to recover the value of another component?
- How to use select option in react js?
- How to auto generate sound code if data increases
- How to mock a method which is part of a node-module using jest?
- How to pass values from child component to parent in ReactJS
- How to combine react-i18next with Semantic UI label tag?
- How do I customize variables to prevent overwriting styles?
- React calling function using useEffect multiple time
- Why only 1 function out of two gets executed in onClick event
- How to change color onClick on every icon seperatly? React, styled-components
- TypeError Cannot read property 'find' of undefined
- Reactjs - writing a function to enable a button on validation of input text
- What is the Antd type for form onFinish?
- Trying to return jsx from an event handler onSubmit of the form
- How to render post in different layout getting from same parent component in reactjs
- Material UI TextField input type="date" doesn´t get event.target.value
- Placement of conditional elements using JSON form schemas
- Successfully POST form data to Express App, use sequelize to insert into MySQL database