diff --git a/src/config.ts b/src/config.ts index f5ac7de..cead3e9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,7 +2,7 @@ import { loadConfig } from 'c12' // Get loaded config const { config } = await loadConfig({ - name: 'reverse-proxy', + name: 'tls', }) export { config } diff --git a/src/keys.ts b/src/keys.ts index d22f876..4493758 100644 --- a/src/keys.ts +++ b/src/keys.ts @@ -1,11 +1,6 @@ import crypto from 'node:crypto' import forge, { pki, tls } from 'node-forge' - -interface GenerateCertOptions { - altNameIPs?: string[] - altNameURIs?: string[] - validityDays?: number -} +import type { GenerateCertOptions } from './types' export function generateCert(options?: GenerateCertOptions) { const def: GenerateCertOptions = { diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..69dd533 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,17 @@ +export interface TlsConfig { + ssl: { + commonName: string + countryName: string + stateName: string + localityName: string + organizationName: string + organizationalUnitName: string + validityYears: number + } +} + +export interface GenerateCertOptions { + altNameIPs?: string[] + altNameURIs?: string[] + validityDays?: number +} diff --git a/tls.config.ts b/tls.config.ts index 549467d..9f2b888 100644 --- a/tls.config.ts +++ b/tls.config.ts @@ -1,9 +1,13 @@ +import type { TlsConfig } from './src/types' + export default { - commonName: 'stacks.localhost', - countryName: 'US', - stateName: 'California', - localityName: 'Playa Vista', - organizationName: 'Stacks', - organizationalUnitName: 'Acme', - validityYears: 1, -} + ssl: { + commonName: 'stacks.localhost', + countryName: 'US', + stateName: 'California', + localityName: 'Playa Vista', + organizationName: 'Stacks', + organizationalUnitName: 'Acme', + validityYears: 1, + }, +} satisfies TlsConfig