Skip to content

The Open Source DocuSign Alternative.

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

Imran Khana6f93698b449
diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml
index 22705c2d6..baa4c1f07 100644
--- a/.github/workflows/e2e-tests.yml
+++ b/.github/workflows/e2e-tests.yml
@@ -32,6 +32,9 @@ jobs:
- name: Run Playwright tests
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
if: always()
diff --git a/packages/signing/transports/local-cert.ts b/packages/signing/transports/local-cert.ts
index aed849854..7ed2f5f8b 100644
--- a/packages/signing/transports/local-cert.ts
+++ b/packages/signing/transports/local-cert.ts
@@ -28,9 +28,18 @@ export const signWithLocalCert = async ({ pdf }: SignWithLocalCertOptions) => {
}
if (!cert) {
- cert = Buffer.from(
- fs.readFileSync(process.env.NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH || './example/cert.p12'),
- );
+ let certPath = process.env.NEXT_PRIVATE_SIGNING_LOCAL_FILE_PATH || '/opt/documenso/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({