Coder Social home page Coder Social logo

daquinoaldo / https-localhost Goto Github PK

View Code? Open in Web Editor NEW
270.0 8.0 38.0 578 KB

HTTPS server running on localhost

License: GNU Affero General Public License v3.0

JavaScript 99.17% HTML 0.83%
localhost chrome firefox https https-server http2 ssl certification-authority ca certificate

https-localhost's Introduction

Hi, I'm Aldo D'Aquino! 👋

🧑‍💻 I'm a senior Infrastructure Engineer at @BendingSpoons.
🙌 I'm positive-minded by nature. I adapt to situations. I like new challenges. I learn fast.
💡 I'm extemely curious. I love experiment with new technologies, learn new things, and try new programming languages.
💬 I communicate a lot. I foster dialogue and give honest feedback. I train new hires and mentor some univeristy students.
🌎 I live in Tuscany, close to the sea. This is one of the benefits of fully-remote work, which is a hard requirement for my life balance.
🤹 I'm a public speaker and open-source developer.

Resume

🧑‍💻 Technical Experience

Senior Infrastructure Engineer @ Bending Spoons

October 2020 - Present

Projects

  • Design and implement the monitoring stack, composed by Prometheus, Mimir, and Grafana. Lead the adoption and spread the obserbility culture in the company.
  • Design and implement the Kubernetes clusters and connected facilities for a smooth migration and integration with existing systems.
  • Design and implement a self-desk platform that let teams autonomously bootstrap required resource while automatically enforcing best practices and security checks.
  • Review, redesign and refactor the Evernote cloud infrastructure. Repay technical debt. Optimize costs. Improve developer experience and security. Consolidate the infrastructure and make it more resilient, observable, and operable.

Other resposibilities

  • Maintain and improve infrastructure building blocks, such as Terraform modules, CircleCI orbs, and Helm charts. Maintain platform tools such as monitoring, clusters, and other internal tooling.
  • Assist teams in complex migrations and infrastructure refactorings. Discuss infrastructure choices and review architectural design documents.
  • Train new hires. Provide feedback to teammates. Run performance reviews.
  • Collect data on developers productivity, run user interviews. Pragmatically propose new assets, tooling, or technologies to improve their efficiency. Validate assumptions with PoCs.
  • Propose, discuss, and enforce best practices for the cloud. Provide tooling to ease their adoption.

🧑‍🎓 Education

MSc in ICT Solution Architect (110/110 with honors)

2020 - Pisa University

Master Thesis: Design, prototyping, and validation of a Kubernetes Operator to orchestrate a proprietary IoT platform on Red Hat OpenShift.
Internship @ Extra Red.

Acquired knowledge

  • ICT Infrastructures, Cloud and Green Computing
  • Parallel and Distributed Systems
  • ICT Risk Assessment
  • Cryptography, Security Methods and Verification, Cloud Security
  • Mobile and Cyber-physical Systems, IoT
  • Peer to Peer Systems, Blockchains
  • Artificial Intelligence, Smart Applications
  • Information Retrieval
  • Data Mining
  • Database design
  • Computability and Complexity, Numerical Computing, Statistics and Probability Theory
  • Algorithm Engineering

Projects

  • ArtGuide: AR, AI project. I lead user stories and product desing and implemented the core service and the deployment pipelines.
  • BeepBeep: Web application to keep track of our fitness runs. We split a monolith in a microservices application.
  • COBrA: An Ethereum blockchain DAPP.
  • eWee: Ensuring Wellness with Energy Efficiency, a domotic IoT project.

Bachelor in Computer Science

Final Thesis: Docker Orchestrator for Web Hosting. The project is available on daquinoaldo/Pier.

🎙️ Public Speaking

📝 Latest posts on Medium

Advantages of the solution 🕵️‍♂️

A clean and tidy server, with nothing installed on but Docker...

February 6, 2021

TL; DR Stackbit is fine if you want a modern and static blog, in less than 1 hour, without web...

April 26, 2020

My server setup: reverse-proxy and free SSL on Docker thanks to Traefik I show you my VPS setup...

March 26, 2020

https-localhost's People

Contributors

andrecarlucci avatar blainsadler avatar daquinoaldo avatar dependabot[bot] avatar eomm avatar github-actions[bot] avatar gstvribs avatar maxim-mazurok avatar patrikelfstrom avatar rgoldfinger-quizlet avatar rsip22 avatar stutrek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

https-localhost's Issues

Error in the documentation

Instead of
const httpsLocalhost = require("https-localhost")();
the documentation reads
const app = require("https-localhost")()
in the npm documentation about the package

Server timeout: Cannot read property 'replace' of undefined

Pretty simple I run the server and all works fine and dandy before it times out.

CLI:

http to https redirection active.
Server running on port 443.
Unexpected error undefined:
TypeError: Cannot read property 'replace' of undefined
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build && CERT_PATH=./ssl/ serve build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-07-28T02_53_09_689Z-debug.log

Log:

1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~build: PATH: /usr/local/lib/node_modules/np$
9 verbose lifecycle [email protected]~build: CWD: /root/vldy.org/client
10 silly lifecycle [email protected]~build: Args: [ '-c', 'react-scripts build &&$
11 silly lifecycle [email protected]~build: Returned: code: 1  signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `react-scripts build && CERT_PAT$
13 verbose stack Exit status 1 
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/n$
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/n$
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
14 verbose pkgid [email protected]
15 verbose cwd /root/vldy.org/client
16 verbose Linux 4.15.0-52-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v10.16.0
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] build: `react-scripts build && CERT_PATH=./ssl/ serve $
22 error Exit status 1
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional lo$
24 verbose exit [ 1, true ]

JAVA_HOME Set on Windows, Fails (access denied)

Bug description
https://puu.sh/H4RuS/03a83a5e5b.png

Expected behavior
A clear and concise description of what you expected to happen.
Got the mkcert popup to install the cert, but then it try keyimport or something after which it fails due to JAVA_HOME being set maybe? Access denied in the jdk folder? I tried removing JAVA_HOME from my enviroment variables and restarting and trying again, still same problem

System information (please complete the following information):
Windows 10
Latest Version

API to use the generated certificates

How would you like to expand the functionalities?
Ability to generate and use certs directly for the existing server

Are there alternatives?

  • Alternative is to use express app included in htttps-localhost but it cannot be used in cases like socket since app.listen won't work.
    https://socket.io/docs/#Using-with-Express
  • Another alternative is to use mkcert directly to generate the cert. This is an extra step to download the certs whereas https-localhost does that automatically and developer doesn't have to run commands for that

Is it a breaking change?
Probably yes, depending upon what would be resulting API when this feature is implemented

Generate certificates at first run

Since the postinstall script asking for sudo permissions makes problems, generate the certificates at first run.

The ./cert/generate.js script will be moved in ./certs.js. If the index.js won't find the certificates, them will be generated by this script.

Proposed by @stutrek in #7 in comments.

https server not working with socket.io

Bug description
Socket.io isn't running with this server.

To Reproduce
Steps to reproduce the behavior:
try using socket.io with the library

Expected behavior
the websocket should receive messages, but doesn't

System information (please complete the following information):

  • OS: Windows 10 20H2 19042.928
  • App version 4.6.4

The process cannot access the file because it is being used by another process.

These are the logs:

Generating certificates...
[0] Certificates path: C:\Users\roberto.rodriguez\AppData\Roaming\https-localhost.
[0] Downloading the mkcert executable...
[0] Running mkcert to generate certificates...
[0] (node:13992) UnhandledPromiseRejectionWarning: Error: Command failed: C:\Users\roberto.rodrigu4.exe -install -cert-file C:\Users\roberto.rodriguez\AppData\Roaming\https-localhost\localhost.crtocalhost\localhost.key localhost
[0] The process cannot access the file because it is being used by another process.
[0]
[0] at ChildProcess.exithandler (child_process.js:294:12)
[0] at ChildProcess.emit (events.js:182:13)
[0] at maybeClose (internal/child_process.js:962:16)

Unable to configure CORS

Bug description
Cannot configure CORS to return specific origins in preflight response headers, because it's handled by the library, which automatically returns wildcards. It is a problem because there are some cases in which browsers reject wildcards due to security reasons.

My specific case is trying to make XHR requests with the withCredentials flag set to true, which fails as documented here.

This problem was introduced in version 4.6.0, specifically in #47. If I use version 4.5.1, it works fine, because the preflight requests reaches my app's CORS middleware.

To Reproduce
Steps to reproduce the behavior:

  1. Run an express server with https-localhost
  2. Make an XHR request with withCredentials set to true with a modern browser

Expected behavior

  1. The request should fail because no Access-Control-Allow-Origin was set, not because a wildcard was sent.

If you still want the library to allow any origin easily, maybe add an option when initializing the server at least, so the programmer knows that it's enabling it, at its own risk

System information:

  • OS: macOS 10.5.5 (Catalina)
  • App version: 4.6.0
  • Node version: 13.3.0
  • Chrome 84.0.4147.135 (Official Build) (64-bit)

Thanks!

File exists: /usr/local/bin/serve

I've serve installed on my computer:

$ which serve
/usr/local/bin/serve

Hence, when I do npm i -g --only=prod https-localhost, I get an error during the installation:

npm i -g --only=prod https-localhost
npm ERR! code EEXIST
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/https-localhost/index.js
npm ERR! dest /usr/local/bin/serve
npm ERR! errno -17
npm ERR! EEXIST: file already exists, symlink '../lib/node_modules/https-localhost/index.js' -> '/usr/local/bin/serve'
npm ERR! File exists: /usr/local/bin/serve
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2021-01-11T17_01_48_121Z-debug.log

To me, it would make sense if the binary was called https-localhost or similar. Currently, it is called serve.

does this work for local LAN device accesses?

Sorry if this is not the right place to ask this, but I'm kind of confused if this server works on LAN environment, say visiting the desktop server on the mobile device connected to the same wifi network. I kept getting error messages like this one discussed here. (all the openssl commands behaves exactly like what's described)
Seems to be certification problems, but I'm really not familiar with these, so a little help would be much appreciated.

Oh and btw, when generating the certificates, looks like there's some logging issue too:

PS D:\workspace\example-3d\show-cases\build> serve .
Serving static path: .
Generating certificates...
Certificates path: C:\Users\YunHsiao\AppData\Roaming\https-localhost. Never modify nor share this files.
Running mkcert to generate certificates...
http to https redirection active.
Certificates generated, installed and trusted. Ready to go!
Server running on port 443.
{ [Error: ENOENT: no such file or directory, open 'D:\workspace\example-3d\show-cases\build\"C:\Users\YunHsiao\AppData\Roaming\https-localhost\mkcert.log"']
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path:
   'D:\\workspace\\example-3d\\show-cases\\build\\"C:\\Users\\YunHsiao\\AppData\\Roaming\\https-localhost\\mkcert.log"' }
{ [Error: ENOENT: no such file or directory, open 'D:\workspace\example-3d\show-cases\build\"C:\Users\YunHsiao\AppData\Roaming\https-localhost\mkcert.err"']
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path:
   'D:\\workspace\\example-3d\\show-cases\\build\\"C:\\Users\\YunHsiao\\AppData\\Roaming\\https-localhost\\mkcert.err"' }

How to use as dependency with continuous integration environment

I have a project that has added https-localhost as a dependency. We have a Jenkins continuous integration server that checks out our code from git and then installs the npm modules so that it can build our app. After the npm modules are installed, the postinstall script for https-localhost runs and it generates the certificates but then get prompted to enter a password. I was wondering how other people handle this situation. I know I could pass the --ignore-scripts flag to npm but that ignores all post-install scripts and I cannot do that.

> [email protected] postinstall /opt/node/myapp/node_modules/https-localhost
> node cert/generate.js

Generating certificates...
Downloading the mkcert executable...
Running mkcert to generate certificates...
[sudo] password for appuser:

You could possibly check for an environment variable and then if present skip the postinstall.

https-localhost_skip_postintall="yes" npm install

Then cert/generate.js would have to updated to check for the https-localhost_skip_postinstall environment variable and not generate the certificates.

Parse error

Bug description
Hi, I'm trying to npm run serve once the https-localhost dependency is installed to use ssl and it sends me the following compilation error message.

Failed to compile.

./node_modules/https-localhost/index.js 1:0
Module parse failed: Unexpected character '#' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> #!/usr/bin/env node
| 
| const path = require("path")

I put the following lines in my js file, I tried to find information about it but I can't solve the problem, I appreciate any possible help.

const app = require("https-localhost")()
// app is an express app, do what you usually do with express
app.listen(port)

System information (please complete the following information):

  • OS: MacOS X Mojave
  • App version 4.4.0

Ability to add server headers

How would you like to expand the functionalities?
I am currently running this from an npm script "serve": "serve dist" and that works great. However I need to add certain headers to the server. For my case I am using a wasm file that requires SharedArrayBuffer. To enable this I need to add these headers to the http server

Cross-Origin-Resource-Policy", "same-origin
Cross-Origin-Embedder-Policy", "require-corp"
Cross-Origin-Opener-Policy", "same-origin

Maybe a simple config file that the server can read from to set all options

Is it a breaking change?
I don't think this should be a breaking change as it is optional

Ability to set a custom domain in the cli

How would you like to expand the functionalities?
Be able to set a custom domain like you can set a custom port.
This to be able to serve with a custom ip/domain for debugging from another device.

Are there alternatives?
Not that I know of.

Is it a breaking change?
No.

Problems with SPA routing

Hi, i'm having two issues with this lib when i'm trying to serve my react spa.

The first is: when i access directly a route work well, but when i try to do a refresh the lib just got lost and i receive a 404 (saying Forbidden 403 from rs.sendFile message)
The second is: when i access directly the i receive a Forbidden from node.js file system, because relative are suspicious to node.

i'm working on a PR for this issue.

Mac M1 Chip Support

Bug description
Does not support M1 Chip's mac.

To Reproduce
Steps to reproduce the behavior:

  1. Install package
  2. Using this package in M1 Mac

Expected behavior
Supports M1 Chip's Mac.

System information (please complete the following information):

  • OS: MacOS Ventura 13.0
  • App version 4.7.1

Additional context
Similar questions: #37

I checked the code about this question, There seems to be no support.

case "darwin":
  return "mkcert-" + MKCERT_VERSION + "-darwin-amd64"
case "linux":
  if (process.arch === "arm" || process.arch === "arm64")
    return "mkcert-" + MKCERT_VERSION + "-linux-arm"
  else return "mkcert-" + MKCERT_VERSION + "-linux-amd64"

Here is my code in project.

import httpsLocalhost from 'https-localhost';

const httpServer = httpsLocalhost();
certs = await httpServer.getCerts();

That's my log about process.arch and process.platform:

console.log(process.arch, process.platform);
<- arm64 darwin

RangeError: Invalid typed array length: -4095

Bug description
As you stated in the README, I'm getting this error only when ENV=production.
I do need that because I'm trying this tool, which looks great, for performance tests.
Reason why I'm opening this issue is that I'm running node 12.14, which is fairly new!

To Reproduce

server.js

const app = require("https-localhost")();
app.get("/", function(req, res) {
  res.send(`hello, http2`);
});

app.listen(4000);
NODE_ENV=production node ./server.js

Expected behavior
not RangeError: Invalid typed array length: -4095

System information (please complete the following information):

  • OS: MacOS Catalina
  • App version 4.4.1
  • Node version 12.14

Doesn't work on Windows

npm i -g https-localhost

Cannot generate the localhost certificate on your platform. Please, consider contacting the developer if you can help.

Windows 10 Pro x64

Importing this library causes uncaught errors to be printed without stack traces

Bug description
Importing this library causes uncaught errors to be printed without stack traces. Note - it is enough to import the library, you don't even have to call any of its functions.

To Reproduce
Steps to reproduce the behavior:

  1. Create a file with the following contents: const httpsLocalhost = require('https-localhost'); throw new Error();
  2. Run the file. The output is:
Unexpected error undefined:

Error

Process finished with exit code 1

Expected behavior
The Error should be logged normally with node.js default behavior, which looks like this:

throw new Error();
^

Error
    at Object.<anonymous> (/Users/myuser/scripts/test.js:1:7)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Process finished with exit code 1

Specifically, the print should contain a stack trace, which is critical to debug applications.

System information (please complete the following information):

  • OS: MacOS Big Sur 11.5.2
  • package version 4.7.0
  • node version 16.13.0

Additional context
This is caused because https-localhost has a global error handler implemented here:

https-localhost/index.js

Lines 101 to 118 in b485509

process.on("uncaughtException", function(err) {
switch (err.errno) {
case "EACCES":
console.error(
"EACCES: run as administrator to use the default ports 443 and 80. " +
"You can also change port with: `PORT=4433 serve ~/myproj`.")
break
case "EADDRINUSE":
console.error("EADDRINUSE: another service on your machine is using " +
"the current port.\nStop it or change port with:" +
"`PORT=4433 serve ~/myproj`.")
break
default:
console.error("Unexpected error " + err.errno + ":\n\n" + err)
break
}
process.exit(1)
})

In my use case, we only use this library during development, according to some environment variable. It looks something like this:

import httpsLocalhost from 'https-localhost';
if (process.env['RUN_HTTPS_LOCALHOST')) { .... }

This means that even though we don't run https-localhost in production, we do import it. This causes the global error handler to run and takes over my app's behavior regarding Errors, making it much harder to debug uncaught errors since they don't have a stack trace because of this issue.
We solved this by using a dynamic import, but the root cause was very hard to find. This is our soluton:

if (process.env['RUN_HTTPS_LOCALHOST')) { 
  const httpsLocalhost = await import('https-localhost').default;
  ...
}

My suggestion:
An imported library should not implement a global error handler. I imagine this is implemented for the CLI, so that uncaught errors will cause the CLI to immediately bail. The error handler logic should only be implemented if this is run through the CLI.

File not found

Hello,

I am starting the server on port 4433 as an example and pointing to the path of my project, but when accessed by the browser, I get an error of not found. What can I do wrong?

Running the local server without https the site works normally

1 Captura de Tela 2019-04-26 às 09 17 24

2 Captura de Tela 2019-04-26 às 09 18 08

Jo-Ann

Bug description
A concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Run with command...
  2. Pass as parameter...
  3. ...

Expected behavior
A clear and concise description of what you expected to happen.

System information (please complete the following information):

  • OS: [e.g. MacOS X Mojave, Ubuntu 18.04, Windows 10 build XXX, ...]
  • App version [e.g. 1.1.2]

Additional context
Add any other context about the problem here.

install the bin command as anything besides serve, maybe 'sserve'

How would you like to expand the functionalities?
This module replaces another npm called 'serve' when installed globally: https://www.npmjs.com/package/serve

It would be nice to install this under 'sserve' or something alternative so we can have access to both.

Are there alternatives?
Manually rename the link and relink the 'serve'.

Is it a breaking change?
This is not a breaking change. Users can run it using a different command, which that is after install.

localhost download file

dear I have install all and run the https local host work good my problem its the php file is downloading wen I tray to visit

Running mkcert to generate certificates Fail

Bug description
I hit an error that can not install the mkcert on window 10
Error: The process cannot access the file because it is being used by another process.

To Reproduce
`import https from 'https';
import httpsLocalhost from 'https-localhost';
import app from './app';

const port = process.env.PORT || 8000;

(async () => {
try {
const certs = await httpsLocalhost().getCerts();
const server = https.createServer(certs, app);
server.listen(port, () => {
console.log(NODE_ENV : ${process.env.NODE_ENV});
console.log(Server started at https://localhost:${port});
});
} catch (error) {
console.log(error);
}
})();`

System information (please complete the following information):

  • OS: Windows 10 Pro - v1909
  • Express Server - 4.17.1
  • Node - v11.6.0

Additional context
Thank you very much.

ERR_SSL_PROTOCOL_ERROR in Chrome

This appears to be running normally in an Electron app.

Node - 12.2.0
Electron - 5.0.6

Loading https://localhost:8000 shows:

This site can’t provide a secure connection
localhost sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

Is there any way to debug this?

Save the certificates outside the node module.

Moving the certificate path to a fixed path, e.g. ~/.https-localhost, will prevent the script to generate a new certificate every time the module is updated.
At the moment, just running npm install will reinstall the module generating again the certificate.

A good path can be:

  • {APPDATA}\https-localhost on Windows
  • ~/.https-localhost on linux
  • ~/Library/Application Support/.https-localhost on darwin

or something similar.

Support for ARM architecture (Raspberry Pi 3 B)

How would you like to expand the functionalities?
Currently, it's not possible to use this package on ARM devices, because the code reads only the platform "linux" and it assumes it should just pull and run the linux-amd64 mkcert binary.

Are there alternatives?
mkcert already provides a binary to run on linux-arm devices.

Is it a breaking change?
Not that I am aware of.

I have already fixed this locally and I have successfully tested the code on Raspberry Pi 3 B. I am creating this issue to report on it and as a basis for opening a Pull Request with this improvement, if that's okay.

The script breaks when you have a username with spaces on Windows.

Bug description
The script breaks when you have a username with spaces on Windows.

To Reproduce
Steps to reproduce the behavior:

  1. Your username has spaces. Ex: "André Carlucci"
  2. serve .
  3. Error: Command failed (mkcert)

Expected behavior
No errors :)

System information (please complete the following information):

  • Windows 10

That can be fixed escaping the path when on Windows platform.

localhost didn’t send any data.

Bug description
I have tried to make this run on 2 different Windows computers with different node versions and both got the same error "localhost didn’t send any data." I used npm to download it using the command "npm i -g --only=prod https-localhost". This happens to websites that do work with normal local hosting in python and node.js.

To Reproduce
Steps to reproduce the behavior:

  1. download node.js on windows
  2. use "npm i -g --only=prod https-localhost"
  3. type 'serve' in dirctory with index.html file
  4. go to local host url

Expected behavior
I expected the website to be running as it would on standard localhost

System information (please complete the following information):

  • OS: Windows 10 and Windows 7
  • App version: node v14.16.0 and v13.14.0

Additional context
I would think it could be because I had the standard local host serve and they both use 'serve' as their command but I only had local host on the Windows 10

Request Aborted error from Android

Bug description
When i try to hit a node server running from an android device, In android device I am getting the Request Aborted issue.

So I read in the readme that when browser shows SSL error we should regenerate the certs I did that as well.

Btw this error doesn't exist in server running without https on localhost.
with android version lower than 9.

The andorid version >9 has made api's to be compulsory with https, and that's why we used this package but we are getting this error .

Any thoughts in direction would be appreciated

Regards

Bug: Intermediate CA not added? Thanks for this module!

Thanks for this module!

Bug description
openssl and https.get are unable to verify the first certificate () when making a request to a local server created with https-localhost.

To Reproduce
Steps to reproduce the behavior:

  1. Start an https-localhost server on localhost:443 with npx https-localhost
  2. Run openssl s_client -connect localhost:443 -> you will see:
CONNECTED(00000005)
depth=0 O = mkcert development certificate, OU = [email protected]
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 O = mkcert development certificate, OU = [email protected]
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/O=mkcert development certificate/[email protected]
 i:/O=mkcert development CA/[email protected]/CN=mkcert [email protected]
---
Server certificate
  1. Or, make a request using https.get
const https = require('https')
https.get('https://localhost/', (res) => {
        console.log('statusCode:', res.statusCode)
        console.log('headers:', res.headers)

        res.on('data', (d) => {
            process.stdout.write(d)
        })
    }).on('error', (e) => {
        console.error(e)
    })
Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1492:34)
    at TLSSocket.emit (events.js:315:20)
    at TLSSocket._finishInit (_tls_wrap.js:935:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:693:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
}

Expected behavior
The request(s) succeed and are trusted. Based on my googling*, I believe the intermediate CA needs to be returned from the https-localhost server. I did try adding the .crt file to my keychain, and I trusted it, and this error still happens.

*: 1) https://stackoverflow.com/questions/19665863/how-do-i-use-a-self-signed-certificate-for-a-https-node-js-server 2) https://thequietinnovator.com/2015/10/11/how-to-fix-nodejs-cert_untrusted-issues/

System information (please complete the following information):

  • OS: MacOS X Catalina 10.5.4
  • App version 4.5.3

Additional context
I think this would be in scope for this module to handle, right? If not, no worries. Another thought... what if https-localhost created a private letsencrypt cert?

Thanks for your hard work on this module!
D

Jo-Ann

Bug description
A concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Run with command...
  2. Pass as parameter...
  3. ...

Expected behavior
A clear and concise description of what you expected to happen.

System information (please complete the following information):

  • OS: [e.g. MacOS X Mojave, Ubuntu 18.04, Windows 10 build XXX, ...]
  • App version [e.g. 1.1.2]

Additional context
Add any other context about the problem here.

Automated Certificate Management - Heroku

n00b here. How does this work if I've got a dyno running via Heroku and I've setup my dyno to manage my certifications?

https://devcenter.heroku.com/articles/automated-certificate-management and I've set that up for Heroku to get the cert from https://letsencrypt.org

Just trying to understand how https-localhost is able to pick up the automated certificate management in all this or does it not even care about that? Because in your readme you talk about creating certs locally which I do not do myself, https://letsencrypt.org/ does it.

CORS Support

How would you like to expand the functionalities?

When using https-localhost to serve static assets that are loaded by another locally served application via XMLHttpRequest browsers reject the request due to the lack of CORS headers on the response. I'd like to add CORS support so local frontend application development can take advantage of the ease of https-localhost.

Are there alternatives?

You can write a wrapper around https-localhost which adds this functionality, however in the spirit of a quick and easy local https server including this by default seems like a win.

Is it a breaking change?

No, all existing usages will continue to work.

help with binary

If you don't have Node.js installed just use a packaged version! Download it from the release page.

Linux

./https-localhost-linux ~/myproj

I downloaded the linux binary.
chmod +x. run in folder with basic html file
Do i need to download additional files?

anc@-zb:~/Desktop/projects/web3/test$ /home/anc/tools/https-hosting/https-localhost-linux
pkg/prelude/bootstrap.js:1697
throw error;
^

Error: Cannot find module 'express'
Require stack:

  • /snapshot/https-localhost/index.js
  1. If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)
    at Function._resolveFilename (pkg/prelude/bootstrap.js:1776:46)
    at Function.Module._load (node:internal/modules/cjs/loader:772:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at Module.require (pkg/prelude/bootstrap.js:1676:31)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object. (/snapshot/https-localhost/index.js)
    at Module._compile (pkg/prelude/bootstrap.js:1751:22)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/snapshot/https-localhost/index.js' ],
    pkg: true
    }

Running on Mac as a non-admin user

Bug description
When running on a Mac as a non-admin user it asks for a sudo password then says I'm not in the sudoers file (because I'm not admin). I installed mkcert normally and ran mkcert -install. Could there be a flag for when you already have mkcert installed or something?

To Reproduce
Steps to reproduce the behavior:

  1. Run as non-admin user on Mac

Expected behavior
Not ask for sudo password

System information (please complete the following information):

  • OS: MacOS X Catalina 10.15.7 (I would update to Big Sur but I have a mid-2014 Macbook so updating is disabled for now)
  • App version [e.g. 1.1.2]: Just installed today, so I guess it's latest

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.