diff --git a/packages/auto-id/src/certificateManager.ts b/packages/auto-id/src/certificateManager.ts index 940f7365..1687c9db 100644 --- a/packages/auto-id/src/certificateManager.ts +++ b/packages/auto-id/src/certificateManager.ts @@ -13,7 +13,6 @@ import { Crypto } from '@peculiar/webcrypto' import * as x509 from '@peculiar/x509' import { KeyObject, createPublicKey } from 'crypto' import { doPublicKeysMatch, pemToPublicKey } from './keyManagement' -import { randomSerialNumber } from './utils' const crypto = new Crypto() x509.cryptoProvider.set(crypto) @@ -67,10 +66,6 @@ export class CertificateManager { return new x509.Name([[commonNameAttr]]) } - // protected static toCommonName(subjectName: string): JsonName { - // return [{ '2.5.4.3': [subjectName] }] // OID for commonName - // } - static prettyPrintCertificate(cert: x509.X509Certificate): void { console.log('Certificate:') console.log('============') @@ -241,7 +236,6 @@ export class CertificateManager { notAfter.setDate(notBefore.getDate() + validityPeriodDays) let certificateBuilder = await x509.X509CertificateGenerator.create({ - serialNumber: randomSerialNumber().toString(), issuer: csr.subject, subject: csr.subject, notBefore, diff --git a/packages/auto-id/src/utils.ts b/packages/auto-id/src/utils.ts index b9630f1a..e7ac9a94 100644 --- a/packages/auto-id/src/utils.ts +++ b/packages/auto-id/src/utils.ts @@ -23,16 +23,6 @@ export function derEncodeSignatureAlgorithmOID(oid: string): Uint8Array { return new Uint8Array([...sequenceHeader, ...new Uint8Array(berArrayBuffer), ...nullParameter]) } -export function randomSerialNumber(): bigint { - // Generate 20 random bytes - const bytes = randomBytes(20) - // Convert bytes to a BigInt - let serial = BigInt('0x' + bytes.toString('hex')) - // Shift right by 1 to ensure the number is positive - serial = serial >> BigInt(1) - return serial -} - export function addDaysToCurrentDate(days: number): Date { const currentDate = new Date() // This gives you the current date and time currentDate.setUTCDate(currentDate.getUTCDate() + days) // Adds the specified number of days