fix: changed the default file path for local certs (#1277)

Changed the default value of NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH env
variable
This commit is contained in:
Imran Khan
2024-09-06 09:39:25 +05:30
committed by GitHub
parent bdc4ec1a31
commit a6f93698b4
2 changed files with 15 additions and 3 deletions

View File

@@ -32,6 +32,9 @@ jobs:
- name: Run Playwright tests - name: Run Playwright tests
run: npm run ci run: npm run ci
env:
# Needed since we use next start which will set the NODE_ENV to production
NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH: './example/cert.p12'
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: always() if: always()

View File

@@ -28,9 +28,18 @@ export const signWithLocalCert = async ({ pdf }: SignWithLocalCertOptions) => {
} }
if (!cert) { if (!cert) {
cert = Buffer.from( let certPath = process.env.NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH || '/opt/documenso/cert.p12';
fs.readFileSync(process.env.NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH || './example/cert.p12'),
); // We don't want to make the development server suddenly crash when using the `dx` script
// so we retain this when NODE_ENV isn't set to production which it should be in most production
// deployments.
//
// Our docker image automatically sets this so it shouldn't be an issue for self-hosters.
if (process.env.NODE_ENV !== 'production') {
certPath = process.env.NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH || './example/cert.p12';
}
cert = Buffer.from(fs.readFileSync(certPath));
} }
const signature = signWithP12({ const signature = signWithP12({