Home

Awesome

@rsbuild/plugin-basic-ssl

Generate an untrusted, self-signed certificate for the HTTPS server.

The Basic SSL plugin will automatically generate a self-signed certificate and set the server.https option. When you visit the page, your browser will indicate that the certificate is not trusted. You can access the HTTPS page after manually confirming this.

<p> <a href="https://npmjs.com/package/@rsbuild/plugin-basic-ssl"> <img src="https://img.shields.io/npm/v/@rsbuild/plugin-basic-ssl?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" /> </a> <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" /> </p>

Usage

Install:

npm add @rsbuild/plugin-basic-ssl -D

Add plugin to your rsbuild.config.ts:

// rsbuild.config.ts
import { pluginBasicSsl } from "@rsbuild/plugin-basic-ssl";

export default {
  plugins: [pluginBasicSsl()],
};

Then visit the https URL of the page, and confirm in your browser.

Options

filename

Filename of the generated certificate.

pluginBasicSsl({
  filename: "foo.pem",
});

outputPath

Output path of the generated certificate.

import path from "node:path";

pluginBasicSsl({
  outputPath: path.join(__dirname, "node_modules/.cache/cert"),
});

selfsignedAttrs

Attributes passing to selfsigned, see selfsigned for details.

const defaultAttrs = [{ name: "commonName", value: "localhost" }];
pluginBasicSsl({
  selfsignedAttrs: [{ name: "commonName", value: "example.com" }],
});

selfsignedOptions

Options passing to selfsigned, see selfsigned - Options for details.

const defaultOptions = {
  days: 30,
  keySize: 2048,
};
pluginBasicSsl({
  selfsignedOptions: {
    days: 100,
  },
});

License

MIT.