1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/kube-auth-proxy/kube-auth-proxy-cert.ts
Jari Kolehmainen 7207edd8f2 refactor
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
2022-03-10 16:58:58 +02:00

34 lines
932 B
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import path from "path";
import type * as selfsigned from "selfsigned";
type SelfSignedGenerate = typeof selfsigned.generate;
export function getKubeAuthProxyCertificate(generate: SelfSignedGenerate): selfsigned.SelfSignedCert {
const opts = [
{ name: "commonName", value: "Lens Certificate Authority" },
{ name: "organizationName", value: "Lens" },
];
return generate(opts, {
keySize: 2048,
algorithm: "sha256",
days: 365,
extensions: [
{ name: "basicConstraints", cA: true },
{ name: "subjectAltName", altNames: [
{ type: 2, value: "localhost" },
{ type: 7, ip: "127.0.0.1" },
] },
],
});
}
export function getKubeAuthProxyCertificatePath(baseDir: string) {
return path.join(baseDir, "kube-auth-proxy");
}