1
1
import type { X509CreateSelfSignedCertificateOptions } from './X509ServiceOptions'
2
- import type { CredoWebCrypto } from '../../crypto/webcrypto '
2
+ import type { AgentContext } from '../../agent '
3
3
4
4
import { AsnParser } from '@peculiar/asn1-schema'
5
5
import {
@@ -14,7 +14,7 @@ import * as x509 from '@peculiar/x509'
14
14
import { Key } from '../../crypto/Key'
15
15
import { KeyType } from '../../crypto/KeyType'
16
16
import { compress } from '../../crypto/jose/jwk/ecCompression'
17
- import { CredoWebCryptoKey } from '../../crypto/webcrypto'
17
+ import { CredoWebCrypto , CredoWebCryptoKey } from '../../crypto/webcrypto'
18
18
import { credoKeyTypeIntoCryptoKeyAlgorithm , spkiAlgorithmIntoCredoKeyType } from '../../crypto/webcrypto/utils'
19
19
import { TypedArrayEncoder } from '../../utils'
20
20
@@ -271,16 +271,30 @@ export class X509Certificate {
271
271
}
272
272
}
273
273
274
- public async getData ( crypto ?: CredoWebCrypto ) {
274
+ /**
275
+ * Get the thumprint of the X509 certificate in hex format.
276
+ */
277
+ public async getThumprint ( agentContext : AgentContext ) {
275
278
const certificate = new x509 . X509Certificate ( this . rawCertificate )
276
279
277
- const thumbprint = await certificate . getThumbprint ( crypto )
280
+ const thumbprint = await certificate . getThumbprint ( new CredoWebCrypto ( agentContext ) )
278
281
const thumbprintHex = TypedArrayEncoder . toHex ( new Uint8Array ( thumbprint ) )
282
+
283
+ return thumbprintHex
284
+ }
285
+
286
+ /**
287
+ * Get the data elements of the x509 certificate
288
+ */
289
+ public get data ( ) {
290
+ const certificate = new x509 . X509Certificate ( this . rawCertificate )
291
+
279
292
return {
280
293
issuerName : certificate . issuerName . toString ( ) ,
294
+ issuer : certificate . issuer ,
281
295
subjectName : certificate . subjectName . toString ( ) ,
296
+ subject : certificate . subject ,
282
297
serialNumber : certificate . serialNumber ,
283
- thumbprint : thumbprintHex ,
284
298
pem : certificate . toString ( ) ,
285
299
notBefore : certificate . notBefore ,
286
300
notAfter : certificate . notAfter ,
0 commit comments