mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
fix: support cert file encodings
This commit is contained in:
@ -19,6 +19,7 @@ NEXTAUTH_URL='http://localhost:3000'
|
|||||||
# SIGNING
|
# SIGNING
|
||||||
CERT_FILE_PATH=
|
CERT_FILE_PATH=
|
||||||
CERT_PASSPHRASE=
|
CERT_PASSPHRASE=
|
||||||
|
CERT_FILE_ENCODING=
|
||||||
|
|
||||||
# MAIL (NODEMAILER)
|
# MAIL (NODEMAILER)
|
||||||
# SENDGRID
|
# SENDGRID
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { PDFDocument, PDFHexString, PDFName, PDFNumber, PDFString } from "pdf-lib";
|
import { PDFDocument, PDFHexString, PDFName, PDFNumber, PDFString } from "pdf-lib";
|
||||||
|
|
||||||
|
|
||||||
const fs = require("fs");
|
import fs from "fs";
|
||||||
// Local copy of Node SignPDF because https://github.com/vbuch/node-signpdf/pull/187 was not published in NPM yet. Can be switched to npm packge.
|
// Local copy of Node SignPDF because https://github.com/vbuch/node-signpdf/pull/187 was not published in NPM yet. Can be switched to npm packge.
|
||||||
const signer = require("./node-signpdf/dist/signpdf");
|
const signer = require("./node-signpdf/dist/signpdf");
|
||||||
|
|
||||||
@ -9,7 +9,9 @@ export const addDigitalSignature = async (documentAsBase64: string): Promise<str
|
|||||||
// Custom code to add Byterange to PDF
|
// Custom code to add Byterange to PDF
|
||||||
const PDFArrayCustom = require("./PDFArrayCustom");
|
const PDFArrayCustom = require("./PDFArrayCustom");
|
||||||
const pdfBuffer = Buffer.from(documentAsBase64, "base64");
|
const pdfBuffer = Buffer.from(documentAsBase64, "base64");
|
||||||
const p12Buffer = fs.readFileSync(process.env.CERT_FILE_PATH || "ressources/cert.p12");
|
const p12Buffer = fs.readFileSync(process.env.CERT_FILE_PATH || "ressources/certificate.p12", {
|
||||||
|
encoding: (process.env.CERT_FILE_ENCODING as BufferEncoding) || null,
|
||||||
|
});
|
||||||
const SIGNATURE_LENGTH = 12000;
|
const SIGNATURE_LENGTH = 12000;
|
||||||
|
|
||||||
const pdfDoc = await PDFDocument.load(pdfBuffer);
|
const pdfDoc = await PDFDocument.load(pdfBuffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user