Skip to content

Commit 396e4c8

Browse files
committed
Document generating & trusting a root cert on OS/X
1 parent 7411a62 commit 396e4c8

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

docs-v2/_docs/proxying.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,14 @@ A few caveats:
169169
add it to your trusted certs then anyone getting hold of it could potentially
170170
get access to any service you use on the web.
171171
172-
TODO: Document how to generate such a keystore, and how to trust its
173-
certificate, on Linux, OS/X & Windows.
174-
172+
> See [this script](https://github.com/tomakehurst/wiremock/blob/master/scripts/create-ca-cert.sh)
173+
> for an example of how to build a valid self-signed root certificate called
174+
> ca-cert.crt already imported into a keystore called ca-cert.jks.
175+
>
176+
> On OS/X it can be trusted by dragging ca-cert.crt onto Keychain Access,
177+
> double clicking on the certificate and setting SSL to "always trust".
178+
>
179+
> Please raise PRs to add documentation for other platforms.
175180
176181
Proxying of HTTPS traffic when the proxy endpoint is also HTTPS is problematic;
177182
Postman seems not to cope with an HTTPS proxy even to proxy HTTP traffic. Older

scripts/ca-cert.conf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[req]
2+
default_bits = 4096
3+
prompt = no
4+
default_md = sha256
5+
distinguished_name = req_distinguished_name
6+
x509_extensions = v3_ca
7+
default_days = 36525
8+
9+
[req_distinguished_name]
10+
C = GB
11+
ST = London
12+
O = WireMock
13+
CN = WireMock Local Self Signed Root Certificate
14+
15+
[v3_ca]
16+
subjectKeyIdentifier = hash
17+
authorityKeyIdentifier = keyid:always
18+
basicConstraints = critical, CA:TRUE
19+
keyUsage = critical, keyCertSign, cRLSign

scripts/create-ca-keystore.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
read -r -s -p "Please enter a password for the key & keystore (default: password):" PASSWORD
5+
PASSWORD=${PASSWORD:=password}
6+
openssl req -x509 -newkey rsa:2048 -utf8 -days 3650 -nodes -config ca-cert.conf -keyout ca-cert.key -out ca-cert.crt
7+
openssl pkcs12 -export -inkey ca-cert.key -in ca-cert.crt -out ca-cert.p12 -password "pass:$PASSWORD"
8+
keytool -importkeystore -deststorepass "$PASSWORD" -destkeypass "$PASSWORD" -srckeystore ca-cert.p12 -srcstorepass "$PASSWORD" -deststoretype jks -destkeystore ca-cert.jks
9+
rm ca-cert.key ca-cert.p12

0 commit comments

Comments
 (0)