Skip to content

Commit 2bbb4e9

Browse files
committed
update readme mkcert.md
1 parent 5012090 commit 2bbb4e9

File tree

3 files changed

+60
-45
lines changed

3 files changed

+60
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ It's mitm http/https proxy. It outputs the https request and response for test.
77
3. https certificate.
88

99
If you want to install self-signed certificate, you could use [mkcert](https://github.com/FiloSottile/mkcert) to do this.
10-
more info can be found here [mkcert.md](./mkcert.zh.md)
10+
more info can be found here [mkcert.md](mkcert.md)
1111

1212
### Usage
1313
If you want to get all requests and responses about `https://www.exmample.com (192.168.3.3)`

mkcert.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## 📥 Install mkcert
2+
> Do NOT download the binary directly from the Releases page, especially on macOS, as it can lead to issues.
3+
> Instead, follow the installation steps provided in the official [README](https://github.com/FiloSottile/mkcert).
4+
5+
```shell
6+
# Install root CA in the system trust store (requires root privileges).
7+
# The root CA is valid for 10 years.
8+
# To undo this later, you can run: mkcert -uninstall
9+
mkcert -install
10+
11+
# Get the directory where the root CA is stored:
12+
cd "$(mkcert -CAROOT)"
13+
14+
# In this directory, you'll find rootCA.pem and rootCA-key.pem
15+
```
16+
## 📄 Generate Certificates
17+
```shell
18+
# Generate certificate and private key for the domain example.com and its subdomains:
19+
mkcert example.com "*.example.com"
20+
```
21+
## 🔐 Create a Java KeyStore (JKS)
22+
```shell
23+
# Step 1: Convert to PKCS12 format (example.com.p12)
24+
openssl pkcs12 -export \
25+
-in example.com.pem \
26+
-inkey example.com-key.pem \
27+
-out example.com.p12 \
28+
-name example.com \
29+
-CAfile rootCA.pem \
30+
-caname root
31+
32+
# Step 2: Import the PKCS12 file into a Java KeyStore (JKS)
33+
keytool -importkeystore \
34+
-srckeystore example.com.p12 \
35+
-srcstoretype PKCS12 \
36+
-destkeystore example.com.jks \
37+
-deststoretype JKS \
38+
-alias example.com
39+
40+
# 🔍 View the JKS Contents
41+
keytool -list -v -keystore example.com.jks -storepass changeit
42+
```
43+
> You can repeat the keytool -importkeystore step multiple times to import multiple .p12 files into the same JKS.
44+
45+
## 📦 Install the Root CA on Another Machine
46+
```shell
47+
# 1. Copy the rootCA.pem to the target machine.
48+
# 2. Set the CAROOT environment variable to the directory containing rootCA.pem
49+
export CAROOT=$(pwd)
50+
51+
# 3. Verify the environment variable
52+
echo $CAROOT
53+
54+
# 4. Install the root CA into the local trust store on the target machine
55+
mkcert -install
56+
```
57+
> ⚠️ Note: Ensure the JAVA_HOME environment variable is correctly set on the machine.
58+
If not, mkcert will not be able to inject the CA into the Java truststore.
59+

mkcert.zh.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)