mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-09 20:12:10 +10:00
ca groundwork
This commit is contained in:
18
server/plugins/ca.ts
Normal file
18
server/plugins/ca.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { CertificateAuthority } from "../internal/clients/ca";
|
||||
import fs from "fs";
|
||||
import { fsCertificateStore } from "../internal/clients/store";
|
||||
|
||||
let ca: CertificateAuthority | undefined;
|
||||
|
||||
export const useGlobalCertificateAuthority = () => {
|
||||
if (!ca) throw new Error("CA not initialised");
|
||||
return ca;
|
||||
};
|
||||
|
||||
export default defineNitroPlugin(async (nitro) => {
|
||||
const basePath = process.env.CLIENT_CERTIFICATES ?? "./certs";
|
||||
fs.mkdirSync(basePath, { recursive: true });
|
||||
const store = fsCertificateStore(basePath);
|
||||
|
||||
ca = await CertificateAuthority.new(store);
|
||||
});
|
||||
Reference in New Issue
Block a user