Skip to content

Commit

Permalink
Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi3700 committed Jun 20, 2024
1 parent ac70441 commit 441c732
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 16 deletions.
6 changes: 0 additions & 6 deletions packages/auto-id/src/certificateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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('============')
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 0 additions & 10 deletions packages/auto-id/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 441c732

Please sign in to comment.