@@ -16,6 +16,7 @@ import type {
16
16
} from ' sshpk' ;
17
17
import { Base64 } from ' js-base64' ;
18
18
import * as openpgp from ' openpgp' ;
19
+ import * as forge from ' node-forge' ;
19
20
import { useDownloadFileFromBase64 } from ' @/composable/downloadBase64' ;
20
21
21
22
function buf2Hex(buffer : ArrayBuffer ) { // buffer is an ArrayBuffer
@@ -254,6 +255,67 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
254
255
] as LabelValue [];
255
256
}
256
257
258
+ const csr = canParse (inputKeyOrCertificateValue , (value ) => {
259
+ return forge .pki .certificationRequestFromPem (value .toString (), true , false );
260
+ }) as forge .pki .Certificate ;
261
+ if (csr ) {
262
+ return [
263
+ {
264
+ label: ' Type: ' ,
265
+ value: ' Certificate Signing Request' ,
266
+ },
267
+ {
268
+ label: ' Subject: ' ,
269
+ value: csr .subject .attributes .map (a => JSON .stringify (a , null , 2 )).join (' \n ' ),
270
+ multiline: true ,
271
+ },
272
+ {
273
+ label: ' Issuer: ' ,
274
+ value: csr .issuer ?.toString (),
275
+ multiline: true ,
276
+ },
277
+ {
278
+ label: ' Validity: ' ,
279
+ value: JSON .stringify (csr .validity , null , 2 ),
280
+ },
281
+ {
282
+ label: ' Signature: ' ,
283
+ value: csr .signature ,
284
+ },
285
+ {
286
+ label: ' Signature Oid: ' ,
287
+ value: csr .signatureOid ?.toString (),
288
+ },
289
+ {
290
+ label: ' Signature parameters: ' ,
291
+ value: JSON .stringify (csr .signatureParameters , null , 2 ),
292
+ },
293
+ {
294
+ label: ' Signing info: ' ,
295
+ value: JSON .stringify (csr .siginfo , null , 2 ),
296
+ },
297
+ {
298
+ label: ' Serial: ' ,
299
+ value: csr .serialNumber ?.toString (),
300
+ },
301
+ {
302
+ label: ' Extensions: ' ,
303
+ value: JSON .stringify (csr .extensions , null , 2 ),
304
+ multiline: true ,
305
+ },
306
+ {
307
+ label: ' Public Key: ' ,
308
+ value: onErrorReturnErrorMessage (() => forge .pki .publicKeyToPem (csr .publicKey )),
309
+ multiline: true ,
310
+ },
311
+ {
312
+ label: ' Public Key Fingerprint:' ,
313
+ value: onErrorReturnErrorMessage (() => forge .pki .getPublicKeyFingerprint (csr .publicKey )?.toHex ()),
314
+ multiline: true ,
315
+ },
316
+ ] as LabelValue [];
317
+ }
318
+
257
319
const fingerprint = canParse (inputKeyOrCertificateValue , value => parseFingerprint (value .toString ())) as Fingerprint ;
258
320
if (fingerprint ) {
259
321
return [
@@ -280,11 +342,11 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
280
342
value: ' PGP Private Key' ,
281
343
},
282
344
{
283
- label: ' : ' ,
345
+ label: ' Creation Time : ' ,
284
346
value: pgpPrivateKey .getCreationTime ().toString (),
285
347
},
286
348
{
287
- label: ' : ' ,
349
+ label: ' Expiration Time : ' ,
288
350
value: (await pgpPrivateKey .getExpirationTime ())?.toString () || ' ' ,
289
351
},
290
352
{
@@ -301,7 +363,7 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
301
363
},
302
364
{
303
365
label: ' Key ID(s): ' ,
304
- value: pgpPrivateKey .getKeyIDs ().map (k => k .toString ()).join (' ; ' ),
366
+ value: pgpPrivateKey .getKeyIDs ().map (k => k .toHex ()).join (' ; ' ),
305
367
},
306
368
] as LabelValue [];
307
369
}
@@ -314,11 +376,11 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
314
376
value: ' PGP Public Key' ,
315
377
},
316
378
{
317
- label: ' : ' ,
379
+ label: ' Creation Time : ' ,
318
380
value: pgpPublicKey .getCreationTime ().toString (),
319
381
},
320
382
{
321
- label: ' : ' ,
383
+ label: ' Expiration Time : ' ,
322
384
value: (await pgpPublicKey .getExpirationTime ())?.toString () || ' ' ,
323
385
},
324
386
{
@@ -335,7 +397,7 @@ const parsedSections = computedAsync<LabelValue[]>(async () => {
335
397
},
336
398
{
337
399
label: ' Key ID(s): ' ,
338
- value: pgpPublicKey .getKeyIDs ().map (k => k .toString ()).join (' ; ' ),
400
+ value: pgpPublicKey .getKeyIDs ().map (k => k .toHex ()).join (' ; ' ),
339
401
},
340
402
] as LabelValue [];
341
403
}
0 commit comments