mirror of
https://github.com/documenso/documenso.git
synced 2026-07-26 01:45:08 +10:00
fix: incorrect certificate health logic (#2028)
This commit is contained in:
@@ -23,10 +23,12 @@ export const loader = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const certStatus = getCertificateStatus();
|
const certStatus = getCertificateStatus();
|
||||||
|
|
||||||
if (certStatus.isAvailable) {
|
if (certStatus.isAvailable) {
|
||||||
checks.certificate = { status: 'ok' };
|
checks.certificate = { status: 'ok' };
|
||||||
} else {
|
} else {
|
||||||
checks.certificate = { status: 'warning' };
|
checks.certificate = { status: 'warning' };
|
||||||
|
|
||||||
if (overallStatus === 'ok') {
|
if (overallStatus === 'ok') {
|
||||||
overallStatus = 'warning';
|
overallStatus = 'warning';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,25 @@ import * as fs from 'node:fs';
|
|||||||
|
|
||||||
import { env } from '@documenso/lib/utils/env';
|
import { env } from '@documenso/lib/utils/env';
|
||||||
|
|
||||||
export type CertificateStatus = {
|
export const getCertificateStatus = () => {
|
||||||
isAvailable: boolean;
|
if (env('NEXT_PRIVATE_SIGNING_TRANSPORT') !== 'local') {
|
||||||
};
|
return { isAvailable: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (env('NEXT_PRIVATE_SIGNING_LOCAL_FILE_CONTENTS')) {
|
||||||
|
return { isAvailable: true };
|
||||||
|
}
|
||||||
|
|
||||||
export const getCertificateStatus = (): CertificateStatus => {
|
|
||||||
const defaultPath =
|
const defaultPath =
|
||||||
env('NODE_ENV') === 'production' ? '/opt/documenso/cert.p12' : './example/cert.p12';
|
env('NODE_ENV') === 'production' ? '/opt/documenso/cert.p12' : './example/cert.p12';
|
||||||
|
|
||||||
const filePath = env('NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH') || defaultPath;
|
const filePath = env('NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH') || defaultPath;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fs.accessSync(filePath, fs.constants.F_OK | fs.constants.R_OK);
|
fs.accessSync(filePath, fs.constants.F_OK | fs.constants.R_OK);
|
||||||
|
|
||||||
const stats = fs.statSync(filePath);
|
const stats = fs.statSync(filePath);
|
||||||
|
|
||||||
return { isAvailable: stats.size > 0 };
|
return { isAvailable: stats.size > 0 };
|
||||||
} catch {
|
} catch {
|
||||||
return { isAvailable: false };
|
return { isAvailable: false };
|
||||||
|
|||||||
Reference in New Issue
Block a user