Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Jun 1, 2024
1 parent c5bce74 commit 97961e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { log } from '@stacksjs/logging'
import { CAC } from 'cac'
import { version } from '../package.json'

import { CreateRootCA, addCertToSystemTrustStoreAndSaveCerts, generateCert } from '../src'
import { addCertToSystemTrustStoreAndSaveCerts, createRootCA, generateCert } from '../src'
const cli = new CAC('tlsx')

interface Options {
Expand All @@ -28,22 +28,11 @@ cli
.action(async (domain: string, options?: Options) => {
domain = domain ?? options?.domain

log.debug(`Generating a self-signed SSL certificate for domain: ${domain}`)
log.info(`Generating a self-signed SSL certificate for: ${domain}`)
log.debug('Options:', options)

const certFilePath = `${os.homedir()}/.stacks/ssl/stacks.localhost.crt`

// Check if the certificate is expired or domain already exists

log.info(`Start to generate a new certificate for domain: ${domain}`)

// Create a new Root CA
const CAcert = await CreateRootCA()

// await generateCert()
const CAcert = await createRootCA()
const HostCert = await generateCert('Tlsx Stacks RootCA', domain, CAcert)

// await addCertToSystemTrustStoreAndSaveCerts()
await addCertToSystemTrustStoreAndSaveCerts(HostCert, CAcert.certificate)

log.success('Certificate generated')
Expand Down
2 changes: 1 addition & 1 deletion src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const DEFAULT_L = 'Melbourne'
const DEFAULT_O = 'Tlsx Stacks RootCA'

// Generate a new Root CA Certificate
export async function CreateRootCA() {
export async function createRootCA() {
// Create a new Keypair for the Root CA
const { privateKey, publicKey } = pki.rsa.generateKeyPair(2048)

Expand Down

0 comments on commit 97961e2

Please sign in to comment.