Skip to content

Commit fc4cc85

Browse files
committed
index.html: add Upload MITM certs button/action
1 parent dabc70b commit fc4cc85

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

static/index.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ <h3 style="text-align: center; margin-bottom: 0.125rem">
6868
<button type="button" onclick="window.location.href='/reboot'">
6969
🔁 Reboot device
7070
</button>
71+
<button id="upload-certs-btn" type="button">
72+
📤 Upload MITM certs (.tar.gz)
73+
</button>
74+
<input
75+
type="file"
76+
id="cert-file"
77+
accept=".tar.gz"
78+
style="display: none"
79+
/>
7180
</div>
7281
</fieldset>
7382
{CONFIG_VALUES}
@@ -89,6 +98,41 @@ <h3 style="text-align: center; margin-bottom: 0.125rem">
8998
window.location.href = `/download?filename=${encodeURIComponent(filename)}`;
9099
});
91100

101+
// Upload certs button logic
102+
document
103+
.getElementById("upload-certs-btn")
104+
.addEventListener("click", () => {
105+
document.getElementById("cert-file").click();
106+
});
107+
document
108+
.getElementById("cert-file")
109+
.addEventListener("change", async () => {
110+
const fileInput = document.getElementById("cert-file");
111+
const file = fileInput.files[0];
112+
if (!file) return; // user cancelled, just ignore
113+
114+
try {
115+
const res = await fetch("/upload-certs", {
116+
method: "POST",
117+
headers: {
118+
"Content-Type": "application/gzip",
119+
},
120+
body: file,
121+
});
122+
123+
const text = await res.text();
124+
if (res.ok) {
125+
alert(`✅ ${text}`);
126+
} else {
127+
alert(`❌ ${text}`);
128+
}
129+
} catch (err) {
130+
alert(`❌ Upload failed: ${err}`);
131+
}
132+
133+
fileInput.value = ""; // reset input so same file can be re-uploaded if needed
134+
});
135+
92136
function setValue(id, value) {
93137
const el = document.getElementById(id);
94138
if (!el) return;

0 commit comments

Comments
 (0)