Skip to content

Commit 7ba8877

Browse files
committed
Remove SSL cert for localhost
This commit removes SSL certification creation and usage when running webviz. The onus is on the process that connects to the internet to handle HTTPS, eg. Azure's firewall.
1 parent 2538035 commit 7ba8877

10 files changed

+54
-289
lines changed

.github/workflows/webviz-config.yml

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ jobs:
6868
6969
- name: 🤖 Run tests
7070
run: |
71-
webviz certificate
7271
webviz preferences --theme default
7372
pytest ./tests --headless --forked
7473
webviz docs --portable ./docs_build --skip-open

INTRODUCTION.md

+25-7
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,32 @@ webviz build ./examples/basic_example.yaml
8282
and then modify `./examples/basic_example.yaml` while the Webviz application is
8383
still running, a hot reload will occur.
8484

85-
#### Localhost certificate
85+
#### Localhost HSTS
8686

87-
For quick local analysis, `webviz-config` uses `https` and runs on `localhost`.
88-
In order to create your personal :lock: `https` certificate (only valid for `localhost`), run
89-
```bash
90-
webviz certificate --auto-install
91-
```
92-
Certificate installation guidelines will be given when running the command.
87+
Previous versions of webviz generated a local certificate to force localhost
88+
connections to go through HTTPS. This is no longer the case and localhost
89+
connections use HTTP. As such, the `webviz certificate` command has been
90+
deprecated.
91+
92+
Some browsers will force HTTPS and require extra steps to remove this security.
93+
Note that this is safe as no external computer may connect to a localhost
94+
server.
95+
96+
If you're having issues connecting to a localhost server running Webviz due to
97+
security issues, perform the following steps:
98+
99+
##### Google Chrome and Chromium
100+
101+
These are the steps to remove HSTS, a security feature that forces HTTPS
102+
connections even though the user has specified HTTP:
103+
104+
1. Navigate to chrome://net-internals/#hsts
105+
2. In the **Delete domain security policies**, type in "localhost" and click
106+
delete
107+
108+
##### Firefox
109+
110+
Firefox does not have issues connecting to localhost addresses over HTTP.
93111

94112
#### User preferences
95113

webviz_config/_docs/open_docs.py

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def _index() -> str:
3030
host="localhost",
3131
port=port,
3232
debug=False,
33-
ssl_context=webviz_config.certificate.LocalhostCertificate().ssl_context,
3433
)
3534

3635

webviz_config/_localhost_token.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77

88

99
class LocalhostToken:
10-
"""Uses a method similar to jupyter notebook (however, here we do it over
11-
https in addition). This method is only used during interactive usage on
12-
localhost, and the workflow is as follows:
10+
"""Uses a method similar to jupyter notebook. This method is only used during
11+
interactive usage on localhost, and the workflow is as follows:
1312
1413
- During the flask app building, a one-time-token (ott) and a cookie_token
1514
is generated.
1615
- When the app is ready, the user needs to "login" using this
17-
one-time-token in the url (https://localhost:{port}?ott={token})
16+
one-time-token in the url (http://localhost:{port}?ott={token})
1817
- If ott is valid - a cookie with a separate token is set, and the
1918
one-time-token is discarded. The cookie is then used for subsequent
2019
requests.
@@ -28,6 +27,7 @@ class LocalhostToken:
2827
2928
The port is used as a postfix on the cookie name in order to make sure that
3029
two different localhost applications running simultaneously do not interfere.
30+
3131
"""
3232

3333
def __init__(self, app: flask.app.Flask, port: int):

webviz_config/certificate/__init__.py

-1
This file was deleted.

webviz_config/certificate/_certificate_generator.py

-228
This file was deleted.

webviz_config/certificate/_localhost_certificate.py

-39
This file was deleted.

webviz_config/command_line.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import sys
12
import json
23
import argparse
34
import pathlib
45

56
from ._build_webviz import build_webviz
6-
from .certificate._certificate_generator import create_ca
77
from ._docs.open_docs import open_docs
88
from ._docs._create_schema import create_schema
99
from ._user_data_dir import user_data_dir
@@ -82,7 +82,7 @@ def main() -> None:
8282
"your personal public key infrastructure",
8383
)
8484

85-
parser_cert.set_defaults(func=create_ca)
85+
parser_cert.set_defaults(func=_dummy_create_ca)
8686

8787
# Add "documentation" parser:
8888

@@ -175,3 +175,14 @@ def entrypoint_schema(args: argparse.Namespace) -> None:
175175
args = parser.parse_args()
176176

177177
args.func(args)
178+
179+
180+
def _dummy_create_ca() -> None:
181+
"""
182+
Print out a message about certs being unnecessary and exit gracefully (ie.
183+
returncode 0)
184+
"""
185+
print(
186+
"The 'certificate' command is no longer needed as Webviz uses HTTP for local servers"
187+
)
188+
sys.exit(0)

0 commit comments

Comments
 (0)