77
88 < head >
99 < meta charset =utf-8 >
10-
10+
1111 < title >
1212 Verify Certificate
1313 </ title >
1919
2020 < link rel =icon href ='images/data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAASFBMVEVHcEwihb8ghsMkhb0hhcEog7gghsMjhL4hhcEghsQhhsIihcEghsMlhLwhhb8hhsIghsM1ga0jhb8hhsIihcEhhsIhhsIghsTjBA94AAAAF3RSTlMATPIXeAbnKIr6n1zZDjvF0QIwuGqyvwIDyU4AAAENSURBVCjPrZPZrsMgDESx2ZewU///n17SVFVF6H2qX1A4ymTGdhj7YXH+FR1c1pSq5MeOSheaIlItOLnBerLQWrCk9F0ZBiXPpeQ+0YBV31gaL1t8kDUrpnBJRtd1oBULEpeDjPB+eFfNGC/7J4mY6yct7rQLnoPN/BnClU/uESvr+HhQP7UQ/WptXvRXZr+x1g4mjTo7drTVGnNkRWFSzy8XYcktODqF5tkXblC5eGsrIGXTu8k0k2/mmQhpFlLaTfQADwJRzGO3EyI/ggAQIWVT7muUp7D1YOeh6g37635Oy6rbPJkcp63ZaUNDA6zqUYX53kykU9xtWuRRnYmKlts9Lkz0f/8BKdlv6w+Edg1IkaSBUwAAAABJRU5ErkJggg== '>
2121 < meta name =viewport content ='width=device-width, initial-scale=1 '>
22-
22+
2323 < script type ='application/ld+json '>
2424 {
2525 "@context" : "https://schema.org" ,
3535 "offers" : { "@type" :"Offer" , "price" :"0" , "priceCurrency" :"GBP" }
3636 }
3737 </ script >
38-
39-
40- < script src ='https://libs.ext-code.com/js/dom/component/component.js '> </ script >
38+
39+
40+ < script src ='https://libs.ext-code.com/js/dom/component/v3.0/ component.js '> </ script >
4141
4242 < script init >
4343 console . clear ( ) ;
4444 console . log ( 'verify-certificate.html' ) ;
4545 console . log ( ) ;
4646 console . json = v => console . log ( JSON . stringify ( v , null , 4 ) ) ;
4747 var nodeforge ;
48-
49-
48+
49+
5050 var df = true , did = 'html'
5151 ;
5252
5656 var menumod ;
5757 var keydown ;
5858 var debug ;
59-
60-
59+
60+
6161 var menu ;
6262
6363
6464 var hdr ;
6565
6666 //:
6767
68-
68+
6969 async function init ( ) {
70-
71-
72- await load ( ) ;
7370
7471
72+ await load ( ) ;
73+
74+
7575 menu = menumod ( ) ;
7676
7777 mod . base . add ( { ext, $, datatype, keydown, menu, menumod} ) ;
8888
8989
9090 initdom ( document . body ) ;
91-
92-
91+
92+
9393 console . log ( 'ready' ) ;
9494 } //init
9595
9696
9797( async ( ) => {
98-
99- mod . stack . add ;
10098
99+ mod . stack . add ;
100+
101101 var { ext} = await import ( 'https://libs.ext-code.com/js/io/ext-loader/ext-loader.m.js' ) ;
102102
103103 var promise = ext . load . libs (
108108 'js/debug/debug.js' ,
109109 ) ;
110110 [ $ , datatype , menumod , keydown , debug ] = await promise ;
111-
112-
111+
112+
113113 mod . stack . complete ;
114-
114+
115115} ) ( ) ;
116116
117117
118118 async function load ( ) {
119-
119+
120120 await Promise . all ( [ load . ext ( ) , load . nodeforge ( ) ] ) ;
121121
122122 } //load
123-
124-
123+
124+
125125 load . ext = async function ( ) {
126-
126+
127127 var res = await fetch ( 'https://raw.githubusercontent.com/javascript-2020/ext-code/main/ext-loader.js' )
128128 var txt = await res . text ( ) ;
129129 ext = eval ( txt ) ;
130130 [ $ , datatype ] = await ext . load . libs ( 'js/dom/$.js' , 'js/core/datatype.js' ) ;
131131
132132 } //ext
133-
134-
133+
134+
135135 load . nodeforge = async function ( ) {
136-
136+
137137 var txt = localStorage [ 'node-forge' ] ;
138138 if ( ! txt ) {
139139 var url = 'https://cdn.jsdelivr.net/npm/node-forge/+esm' ;
149149 //console.log(nodeforge);
150150
151151 } //nodeforge
152-
153-
152+
153+
154154 </ script >
155155
156156
157157 < style >
158-
158+
159159 html
160160 {height : 100% }
161161 body
165165 x509-hdr
166166 {margin-bottom : 20px }
167167
168- .hdr
168+ .hdr
169169 {font-family : arial;position : relative;margin-top : 0 ;margin-bottom : 20px ;background : white;
170170 padding-bottom : 10px ;border-bottom : 3px solid lightblue}
171- .hdr-icon
171+ .hdr-icon
172172 {display : inline-block;text-align : center;background : whitesmoke;border-radius : 5px ;
173173 border : 1px solid lightgray;padding : 5px 3px 0px ;cursor : pointer;margin-right : 10px ;
174174 min-width : 50px }
175- .hdr-icon-img
175+ .hdr-icon-img
176176 {width : 25px ;height : 25px }
177- .hdr-icon-label
177+ .hdr-icon-label
178178 {margin : 2px 0 0 }
179- .hdr-title
179+ .hdr-title
180180 {position : absolute;left : 0 ;right : 0 ;z-index : 0 ;margin : 0 auto}
181181 .hdr-date
182182 {float : right}
183-
183+
184184 input
185185 {padding : 5px 10px ;font-size : 16px }
186186 input [type = button ]
187187 {cursor : pointer}
188-
188+
189189 # result
190190 {display : none;padding : 5px 10px }
191191 .ok
192192 {color : green;border : 1px solid green}
193193 .error
194194 {color : red;border : 1px solid red}
195-
196-
195+
196+
197197 .visually-hidden
198198 {position : absolute !important ;width : 1px !important ;height : 1px !important ;padding : 0 !important ;margin : -1px !important ;overflow : hidden !important ;
199199 clip : rect (0 0 0 0 ) !important ;white-space : nowrap !important ;border : 0 !important }
200-
201-
200+
201+
202202 </ style >
203203
204204 </ head >
205205
206206 < body >
207-
208-
207+
208+
209209 < x509-hdr component =grp v2.0 >
210210 < h1 class =visually-hidden >
211211 Verify Certificate
@@ -215,8 +215,8 @@ <h1 class=visually-hidden>
215215 15 Nov 2025
216216 </ time >
217217 </ x509-hdr >
218-
219-
218+
219+
220220<!--
221221 <div class=hdr>
222222 <a class=hdr-icon href='https://javascript-2020.github.io/'>
@@ -240,7 +240,7 @@ <h1 class=visually-hidden>
240240 </div hdr>
241241-->
242242
243-
243+
244244 < div id =btns >
245245 < input value =clear type =button >
246246 < input value =root type =button >
@@ -260,21 +260,21 @@ <h1 class=visually-hidden>
260260 var $ ;
261261 var datatype ;
262262
263-
263+
264264
265265 var root ;
266266 var chain = [ ] ;
267267
268268
269269 var btn = { } ;
270270
271-
271+
272272 //
273-
273+
274274
275275 function initdom ( ) {
276-
277-
276+
277+
278278 var btns = $ ( '#btns' ) ;
279279
280280 hdr . initdom ( ) ;
@@ -283,46 +283,46 @@ <h1 class=visually-hidden>
283283 $ ( btns , '[value=root]' ) . onclick = btn . root ;
284284 $ ( btns , '[value="add cert"]' ) . onclick = btn . add ;
285285 $ ( btns , '[value=verify]' ) . onclick = btn . verify ;
286-
287-
286+
287+
288288 $ ( '#view' ) . replaceChildren ( ) ;
289-
289+
290290
291291 } //initdom
292-
293-
292+
293+
294294 //:
295295
296296
297297 btn . clear = function ( ) {
298-
298+
299299 root = null ;
300300 chain = [ ] ;
301301 $ ( '#view' ) . replaceChildren ( ) ;
302302 $ ( '#result' ) . style . display = '' ;
303303
304304 } //clear
305305
306-
306+
307307 btn . root = async function ( ) {
308-
308+
309309 root = await load . cert ( 'pem' ) ;
310310 display ( ) ;
311311
312312 } //root
313313
314-
314+
315315 btn . add = async function ( ) {
316-
316+
317317 var cert = await load . cert ( 'import' ) ;
318318 chain . push ( cert ) ;
319319 display ( ) ;
320320
321321 } //add
322-
322+
323323
324324 btn . verify = function ( ) {
325-
325+
326326 if ( ! root ) {
327327 alert ( 'root not set' ) ;
328328 return ;
@@ -337,7 +337,7 @@ <h1 class=visually-hidden>
337337
338338
339339 function display ( ) {
340-
340+
341341 $ ( '#view' ) . replaceChildren ( ) ;
342342 var str = '' ;
343343 if ( ! root ) {
@@ -346,7 +346,7 @@ <h1 class=visually-hidden>
346346 str += root ;
347347
348348 chain . forEach ( cert => {
349-
349+
350350 cert = nodeforge . pki . certificateToPem ( cert ) ;
351351 str += cert ;
352352
@@ -358,13 +358,13 @@ <h1 class=visually-hidden>
358358
359359
360360 async function verify ( ) {
361-
361+
362362 var store = nodeforge . pki . createCaStore ( [ root ] ) ;
363363
364364 $ ( '#result' ) . style . display = 'inline' ;
365-
365+
366366 try {
367-
367+
368368 var result = nodeforge . pki . verifyCertificateChain ( store , chain ) ;
369369 console . json ( result ) ;
370370
@@ -373,18 +373,18 @@ <h1 class=visually-hidden>
373373
374374 }
375375 catch ( err ) {
376-
376+
377377 console . log ( err ) ;
378378 $ ( '#result' ) . textContent = 'verification failed' ;
379379 $ ( '#result' ) . className = 'error' ;
380380
381381 }
382382
383- } //verify
384-
385-
386-
387-
383+ } //verify
384+
385+
386+
387+
388388 load . cert = function ( mode ) {
389389
390390 var resolve , promise = new Promise ( res => resolve = res ) ;
@@ -408,11 +408,11 @@ <h1 class=visually-hidden>
408408 } //onchange
409409
410410 } //cert
411-
412-
413-
411+
412+
413+
414414
415415 </ script >
416-
416+
417417</ html >
418418
0 commit comments