Skip to content

Commit ce1c03d

Browse files
authored
feat: webui supports certificate installation (#25)
1 parent 4cf891d commit ce1c03d

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

assets/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@
125125
background-color: #f5f5f5;
126126
}
127127

128+
.certificate {
129+
position: relative;
130+
display: inline-block;
131+
border: none;
132+
cursor: pointer;
133+
padding-right: 0.5rem;
134+
}
135+
136+
.certificate a {
137+
color: #333;
138+
text-decoration: none;
139+
}
140+
128141
.traffic-table {
129142
width: 100%;
130143
table-layout: fixed;
@@ -321,6 +334,9 @@
321334
<a data-kind="res-body">Copy Response Body</a>
322335
</div>
323336
</div>
337+
<div class="certificate">
338+
<a href="/__proxyfor__/certificate/" target="_blank" title="Install CA certificate for HTTPS Proxy">Certificate</a>
339+
</div>
324340
</div>
325341
</div>
326342
<div class="main-view"></div>

assets/install-certificate.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1 id="install-proxyfors-certificate-authority">Install proxyfor’s
2929
<h2 id="windows">Windows</h2>
3030
</summary>
3131
<p><a
32-
href="http://proxyfor.local/proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
32+
href="./proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
3333
<h3 id="manual-installation">Manual Installation</h3>
3434
<ol type="1">
3535
<li>Double-click the CER file to start the import wizard.</li>
@@ -38,8 +38,8 @@ <h3 id="manual-installation">Manual Installation</h3>
3838
machine. Click Next.</li>
3939
<li>Click Next again.</li>
4040
<li>Leave Password blank and click Next.</li>
41-
<li><strong>Select Place all certificates in the following
42-
store</strong>, then click Browse, and select Trusted Root Certification
41+
<li>Select Place all certificates in the following
42+
store, then click Browse, and select Trusted Root Certification
4343
Authorities.<br />
4444
Click OK and Next.</li>
4545
<li>Click Finish.</li>
@@ -57,7 +57,7 @@ <h3 id="automated-installation">Automated Installation</h3>
5757
<h2 id="linux">Linux</h2>
5858
</summary>
5959
<p><a
60-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
60+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
6161
<h3 id="ubuntudebian">Ubuntu/Debian</h3>
6262
<ol type="1">
6363
<li><code>mv proxyfor-ca-cert.pem /usr/local/share/ca-certificates/proxyfor.crt</code></li>
@@ -74,7 +74,7 @@ <h3 id="fedora">Fedora</h3>
7474
<h2 id="macos">macOS</h2>
7575
</summary>
7676
<p><a
77-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
77+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
7878
<h3 id="manual-installation-1">Manual Installation</h3>
7979
<ol type="1">
8080
<li>Double-click the PEM file to open the Keychain Access
@@ -94,7 +94,7 @@ <h3 id="automated-installation-1">Automated Installation</h3>
9494
<h2 id="ios">iOS</h2>
9595
</summary>
9696
<p><a
97-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
97+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
9898
<h3 id="ios-13">iOS 13+</h3>
9999
<ol type="1">
100100
<li>Use Safari to download the certificate. Other browsers may not open
@@ -110,7 +110,7 @@ <h3 id="ios-13">iOS 13+</h3>
110110
<h2 id="android">Android</h2>
111111
</summary>
112112
<p><a
113-
href="http://proxyfor.local/proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
113+
href="./proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
114114
<h3 id="android-10">Android 10+</h3>
115115
<ol type="1">
116116
<li>Open the downloaded CER file.</li>
@@ -139,7 +139,7 @@ <h3 id="android-10">Android 10+</h3>
139139
<h2 id="firefox">Firefox</h2>
140140
</summary>
141141
<p><a
142-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
142+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
143143
<h3 id="firefox-1">Firefox</h3>
144144
<ol type="1">
145145
<li>Open Options -&gt; Privacy &amp; Security and click View

src/server.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ impl Server {
232232
} else if let Some(id) = path.strip_prefix("/traffic/") {
233233
let query = req.uri().query().unwrap_or_default();
234234
self.handle_get_traffic(&mut res, id, query).await
235+
} else if let Some(path) = path.strip_prefix("/certificate/") {
236+
self.handle_cert_index(&mut res, path).await
235237
} else {
236238
*res.status_mut() = StatusCode::NOT_FOUND;
237239
return Ok(res);

tests/snapshots/cert__cert_page.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
source: tests/cert.rs
3-
expression: text
3+
expression: res.text().await?
44
---
55
<h1 id="install-proxyfors-certificate-authority">Install proxyfor’s
66
Certificate Authority</h1>
@@ -33,7 +33,7 @@ summary:before {
3333
<h2 id="windows">Windows</h2>
3434
</summary>
3535
<p><a
36-
href="http://proxyfor.local/proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
36+
href="./proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
3737
<h3 id="manual-installation">Manual Installation</h3>
3838
<ol type="1">
3939
<li>Double-click the CER file to start the import wizard.</li>
@@ -42,8 +42,8 @@ the certificate – only the current Windows user or everyone on the
4242
machine. Click Next.</li>
4343
<li>Click Next again.</li>
4444
<li>Leave Password blank and click Next.</li>
45-
<li><strong>Select Place all certificates in the following
46-
store</strong>, then click Browse, and select Trusted Root Certification
45+
<li>Select Place all certificates in the following
46+
store, then click Browse, and select Trusted Root Certification
4747
Authorities.<br />
4848
Click OK and Next.</li>
4949
<li>Click Finish.</li>
@@ -61,7 +61,7 @@ href="https://technet.microsoft.com/en-us/library/cc732443.aspx">details</a>).</
6161
<h2 id="linux">Linux</h2>
6262
</summary>
6363
<p><a
64-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
64+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
6565
<h3 id="ubuntudebian">Ubuntu/Debian</h3>
6666
<ol type="1">
6767
<li><code>mv proxyfor-ca-cert.pem /usr/local/share/ca-certificates/proxyfor.crt</code></li>
@@ -78,7 +78,7 @@ href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
7878
<h2 id="macos">macOS</h2>
7979
</summary>
8080
<p><a
81-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
81+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
8282
<h3 id="manual-installation-1">Manual Installation</h3>
8383
<ol type="1">
8484
<li>Double-click the PEM file to open the Keychain Access
@@ -98,7 +98,7 @@ it.</li>
9898
<h2 id="ios">iOS</h2>
9999
</summary>
100100
<p><a
101-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
101+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
102102
<h3 id="ios-13">iOS 13+</h3>
103103
<ol type="1">
104104
<li>Use Safari to download the certificate. Other browsers may not open
@@ -114,7 +114,7 @@ Certificate Trust Settings.</strong> Toggle proxyfor to ON.</li>
114114
<h2 id="android">Android</h2>
115115
</summary>
116116
<p><a
117-
href="http://proxyfor.local/proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
117+
href="./proxyfor-ca-cert.cer">proxyfor-ca-cert.cer</a></p>
118118
<h3 id="android-10">Android 10+</h3>
119119
<ol type="1">
120120
<li>Open the downloaded CER file.</li>
@@ -143,7 +143,7 @@ via the Magisk Manager app.</p>
143143
<h2 id="firefox">Firefox</h2>
144144
</summary>
145145
<p><a
146-
href="http://proxyfor.local/proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
146+
href="./proxyfor-ca-cert.pem">proxyfor-ca-cert.pem</a></p>
147147
<h3 id="firefox-1">Firefox</h3>
148148
<ol type="1">
149149
<li>Open Options -&gt; Privacy &amp; Security and click View

0 commit comments

Comments
 (0)