Skip to content

Commit 97fda5c

Browse files
committed
Update contrib instructions for using TLS
1 parent 3a03056 commit 97fda5c

File tree

2 files changed

+52
-5
lines changed

2 files changed

+52
-5
lines changed

.envrc.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Set this to a local file for curl to write premaster secrets to for Wireshark
2+
SSLKEYLOGFILE=

CONTRIBUTING.md

+50-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ We require a recent version of [Leiningen](https://leiningen.org/), and a minimu
1010

1111
### TLS/SSL
1212

13-
To develop against TLS, (effectively mandatory for HTTP/2+) it's best to install your own root authority and certificates. The [mkcert](https://github.com/FiloSottile/mkcert) tool is very helpful.
13+
To develop against TLS, (effectively mandatory for HTTP/2+) it's helpful to install
14+
your own root authority and certificates. The [mkcert](https://github.com/FiloSottile/mkcert) tool is ideal for that.
15+
While a self-signed certificate will work, it's possible to run into warnings and
16+
odd behavior.
1417

18+
#### Mkcert
1519
An example setup:
1620
```shell
1721
# first check $JAVA_HOME is not empty, mkcert will use it to know where to install
@@ -20,24 +24,65 @@ echo $JAVA_HOME
2024
# this is installs the root certificate authority (CA) for browsers/OS/Java
2125
mkcert -install
2226

23-
# if you have multiple JVMs in use, you will need to install the CA for each
27+
# if you have multiple JVMs in use, you will need to install the CA for each one separately
2428
export JAVA_HOME=/path/to/some/other/jdk
2529
TRUST_STORES=java mkcert -install
2630

2731
# this will generate a cert file and a key file in .pem format
2832
mkcert aleph.localhost localhost 127.0.0.1 ::1
29-
# e.g., aleph.localhost+3-key.pem and aleph.localhost+3.pem
33+
# e.g., aleph.localhost+3.pem and aleph.localhost+3-key.pem
3034
```
3135

36+
If you are using an HTTP tool with its own trust store, like Insomnia, you will
37+
need to add the root CA to its trust store as well.
38+
39+
For Insomnia, it's hidden under the project dropdown in the top center, under
40+
Collection Settings > Client Certificates > CA Certificate. (NB: you don't need
41+
a client certificate, just the CA.)
42+
43+
For curl, you would run something like: `curl --cacert "$(mkcert -CAROOT)/rootCA.pem"`
44+
45+
Warning: As of August 2023, many tools still do not support HTTP/2: Postman,
46+
HTTPie, RapidAPI/Paw, and many others.
47+
48+
#### DNS
49+
You'll need to add `aleph.localhost` to your `/etc/hosts` file, e.g.:
50+
51+
```
52+
127.0.0.1 aleph.localhost
53+
::1 aleph.localhost
54+
```
55+
56+
#### Aleph SslContext
3257
Then, in code, generate an SslContext like:
3358

3459
```clojure
3560
(aleph.netty/ssl-server-context
36-
{:private-key "aleph.localhost+3-key.pem"
37-
:certificate-chain "aleph.localhost+3.pem"
61+
{:certificate-chain "/path/to/aleph.localhost+3.pem"
62+
:private-key "/path/to/aleph.localhost+3-key.pem"
3863
...})
3964
```
4065

66+
#### Wireshark and curl
67+
68+
If you need to debug at the wire level, Wireshark is a powerful, but difficult
69+
to use, tool. It supports TLS decryption, not via the use of certificates (which are
70+
only a starting point), but by recording the actual TLS session keys to a file.
71+
72+
In curl, you can support this by adding an env var called `SSLKEYLOGFILE`, and in
73+
Wireshark's Preferences > Protocols > TLS, set the "(Pre)-Master-Secret log
74+
filename" to the same value. This is a bit of a pain to set up, but once done,
75+
it's very useful.
76+
77+
You would then run something like:
78+
79+
```shell
80+
curl --cacert "$(mkcert -CAROOT)/rootCA.pem" --http2-prior-knowledge --max-time 3 --tls-max 1.2 https://aleph.localhost:11256/
81+
```
82+
83+
*Note* the `--tls-max 1.2`. In testing, it was required or else the session key
84+
log file was empty.
85+
4186
## Testing
4287

4388
`lein test` should be run, and pass, before pushing up to GitHub.

0 commit comments

Comments
 (0)