diff --git a/README.md b/README.md index 34d2be5..fbb1067 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,25 @@ pluginBasicSsl({ }); ``` +### selfsignedAttrs + +Attributes passing to `selfsigned`, see [selfsigned](https://github.com/jfromaniello/selfsigned) for details. + +- **Type:** `CertificateField[]` +- **Default:** + +```ts +const defaultAttrs = [{ name: "commonName", value: "localhost" }]; +``` + +- **Example:** + +```ts +pluginBasicSsl({ + selfsignedAttrs: [{ name: "commonName", value: "example.com" }], +}); +``` + ### selfsignedOptions Options passing to `selfsigned`, see [selfsigned - Options](https://github.com/jfromaniello/selfsigned?tab=readme-ov-file#options) for details. diff --git a/src/index.ts b/src/index.ts index fef74cd..eb2d304 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import type { RsbuildPlugin } from '@rsbuild/core'; -import type { SelfsignedOptions } from 'selfsigned'; +import type { SelfsignedOptions, generate } from 'selfsigned'; import { resolveHttpsConfig } from './util.js'; export const PLUGIN_BASIC_SSL_NAME = 'rsbuild:basic-ssl'; @@ -15,6 +15,10 @@ export type PluginBasicSslOptions = { * @default __dirname */ outputPath?: string; + /** + * Attributes passing to `selfsigned`. + */ + selfsignedAttrs?: Parameters[0]; /** * Options passing to `selfsigned`. */ diff --git a/src/util.ts b/src/util.ts index 30fa1c2..41d991e 100644 --- a/src/util.ts +++ b/src/util.ts @@ -57,7 +57,7 @@ export const resolveHttpsConfig = async ( } const pem = selfsigned.generate( - [{ name: 'commonName', value: 'localhost' }], + options.selfsignedAttrs ?? [{ name: 'commonName', value: 'localhost' }], selfsignedOptions, );