-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
203 lines (174 loc) · 5.11 KB
/
index.html
File metadata and controls
203 lines (174 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Certificate Chain Uploader</title>
<style>
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Arial', sans-serif;
background: #f4f4f9;
color: #333;
line-height: 1.6;
margin: 20px;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background: #fff;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 20px;
max-width: 1200px;
width: 100%;
}
h1 {
text-align: center;
margin-bottom: 20px;
color: #444;
}
p {
text-align: center;
margin-bottom: 20px;
}
label {
font-weight: bold;
display: block;
margin-bottom: 10px;
}
textarea {
width: 100%;
height: 120px;
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-family: 'Courier New', monospace;
font-size: 14px;
resize: vertical;
}
button {
display: block;
width: 100%;
background: #007BFF;
color: #fff;
padding: 10px;
font-size: 16px;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: #0056b3;
}
.output, .response {
margin-top: 20px;
}
.output textarea, .response pre {
background: #f9f9f9;
border: 1px solid #ddd;
padding: 10px;
border-radius: 4px;
font-family: 'Courier New', monospace;
font-size: 14px;
}
.response {
background: #f7f7f7;
border-radius: 4px;
padding: 15px;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}
.response h2 {
margin-bottom: 10px;
color: #555;
}
.center {
text-align: center;
margin-top: 10px;
}
.center a {
text-decoration: none;
color: #007BFF;
}
.center a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Certificate Chain Uploader</h1>
<p>Format your certificates into the required JSON structure and upload them to the Dumbo Certificate Transparency log.</p>
<label for="leafCert">Leaf Certificate:</label>
<textarea id="leafCert" placeholder="Paste your leaf certificate here..."></textarea>
<label for="intermediateCert">Intermediate Certificate:</label>
<textarea id="intermediateCert" placeholder="Paste your intermediate certificate here..."></textarea>
<button id="processButton">Process and Upload</button>
<div class="output">
<h2>Generated JSON</h2>
<textarea id="output" readonly placeholder="The formatted JSON will appear here..."></textarea>
</div>
<div class="response">
<h2>Server Response</h2>
<pre id="serverResponse">Awaiting response...</pre>
</div>
<div class="center">
<p>
Need help? Visit <a href="https://certificate.transparency.dev/" target="_blank">Certificate Transparency</a> or contact me.
</p>
</div>
</div>
<script>
document.getElementById("processButton").addEventListener("click", async () => {
const leafCert = document.getElementById("leafCert").value.trim();
const intermediateCert = document.getElementById("intermediateCert").value.trim();
if (!leafCert || !intermediateCert) {
alert("Please paste both the leaf and intermediate certificates.");
return;
}
const cleanCert = (content) =>
content
.replace(/-----BEGIN CERTIFICATE-----/g, "")
.replace(/-----END CERTIFICATE-----/g, "")
.replace(/\r?\n|\r/g, "");
const cleanedLeaf = cleanCert(leafCert);
const cleanedIntermediate = cleanCert(intermediateCert);
// Create JSON in the required format
const jsonData = {
chain: [cleanedLeaf, cleanedIntermediate]
};
// Display JSON in the output textarea
document.getElementById("output").textContent = JSON.stringify(jsonData, null, 2);
// Send the JSON to the CT log
try {
const response = await fetch("https://dumbo.ctlabs.sectigo.com/ct/v1/add-chain", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(jsonData)
});
if (!response.ok) {
// If response status is not 200, show the HTTP status code
document.getElementById("serverResponse").textContent = `Error: HTTP ${response.status}`;
} else {
// If response status is 200, parse and display JSON response
const result = await response.json();
document.getElementById("serverResponse").textContent = JSON.stringify(result, null, 2);
}
} catch (error) {
document.getElementById("serverResponse").textContent = `Error: ${error.message}`;
}
});
</script>
</body>
</html>