Skip to content
Snippets Groups Projects
Verified Commit 21cec662 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #9734 electronic signature if validate + separate cert and private key

parent 29e8f1f3
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,8 @@
</database>
<electronicSignature>
<enable>false</enable>
<certPath>/home/maarch/Bureau/tcpdf.crt</certPath>
<certPath>/home/maarch/Bureau/tcpdf.crt</certPath><!-- .crt or .p12 or .pem -->
<privateKeyPath>/home/maarch/Bureau/tcpdf.crt</privateKeyPath><!-- if private key and certificate are in the same file, put the same path -->
<password>password</password>
<certInfo>
<name>Maarch</name>
......
......@@ -37,7 +37,6 @@
"ngx-cookie-service": "^2.1.0",
"ngx-scroll-event": "^1.0.8",
"pdfjs-dist": "^2.0.943",
"rxjs": "^6.4.0",
"simple-pdf-viewer": "^2.0.3",
"zone.js": "~0.8.29"
},
......
......@@ -261,7 +261,6 @@ class DocumentController
$processingUser['preferences'] = json_decode($processingUser['preferences'], true);
if ($processingUser['preferences']['notifications']) {
$lang = LangController::get(['lang' => $processingUser['preferences']['lang']]);
$url = UrlController::getCoreUrl() . 'dist/index.html#/documents/' . $id;
EmailController::createEmail([
......@@ -377,21 +376,25 @@ class DocumentController
}
}
$loadedXml = CoreConfigModel::getConfig();
if ($loadedXml->electronicSignature->enable == 'true') {
$certPath = realpath((string)$loadedXml->electronicSignature->certPath);
if (is_file($certPath)) {
$certificate = 'file://' . $certPath;
$info = [
'Name' => (string)$loadedXml->electronicSignature->certInfo->name,
'Location' => (string)$loadedXml->electronicSignature->certInfo->location,
'Reason' => (string)$loadedXml->electronicSignature->certInfo->reason,
'ContactInfo' => (string)$loadedXml->electronicSignature->certInfo->contactInfo
];
$pdf->setSignature($certificate, $certificate, (string)$loadedXml->electronicSignature->password, '', 2, $info);
} else {
return $response->withStatus(400)->withJson(['errors' => 'check certPath']);
$status = StatusModel::getById(['select' => ['reference'], 'id' => $action['next_status_id']]);
if ($status['reference'] == 'VAL' && $document['mode'] == 'SIGN') {
$loadedXml = CoreConfigModel::getConfig();
if ($loadedXml->electronicSignature->enable == 'true') {
$certPath = realpath((string)$loadedXml->electronicSignature->certPath);
$privateKeyPath = realpath((string)$loadedXml->electronicSignature->privateKeyPath);
if (is_file($certPath) && is_file($privateKeyPath)) {
$certificate = 'file://' . $certPath;
$privateKey = 'file://' . $privateKeyPath;
$info = [
'Name' => (string)$loadedXml->electronicSignature->certInfo->name,
'Location' => (string)$loadedXml->electronicSignature->certInfo->location,
'Reason' => (string)$loadedXml->electronicSignature->certInfo->reason,
'ContactInfo' => (string)$loadedXml->electronicSignature->certInfo->contactInfo
];
$pdf->setSignature($certificate, $privateKey, (string)$loadedXml->electronicSignature->password, '', 2, $info);
} else {
return $response->withStatus(400)->withJson(['errors' => 'certPath or privateKeyPath is not valid']);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment