Skip to content

Commit 2536ff8

Browse files
committedJul 1, 2023
Mejoras menores en firma
- Actualizada clase XmlTools - Actualizada clase FacturaeSigner
1 parent 45839c1 commit 2536ff8

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed
 

‎src/Common/FacturaeSigner.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,8 @@ public function sign($xml) {
204204

205205
// Build <ds:KeyInfo /> element
206206
$privateData = openssl_pkey_get_details($this->privateKey);
207-
$modulus = chunk_split(base64_encode($privateData['rsa']['n']), 76);
208-
$modulus = str_replace("\r", '', $modulus);
209-
$exponent = base64_encode($privateData['rsa']['e']);
207+
$modulus = XmlTools::toBase64($privateData['rsa']['n'], true);
208+
$exponent = XmlTools::toBase64($privateData['rsa']['e']);
210209
$dsKeyInfo = '<ds:KeyInfo Id="' . $this->certificateId . '">' . "\n" . '<ds:X509Data>' . "\n";
211210
foreach ($this->publicChain as $pemCertificate) {
212211
$dsKeyInfo .= '<ds:X509Certificate>' . "\n" . XmlTools::getCert($pemCertificate) . '</ds:X509Certificate>' . "\n";

‎src/Common/XmlTools.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static function getDigest($input, $pretty=false) {
146146
public static function getCert($pem, $pretty=true) {
147147
$pem = str_replace("-----BEGIN CERTIFICATE-----", "", $pem);
148148
$pem = str_replace("-----END CERTIFICATE-----", "", $pem);
149-
$pem = str_replace("\n", "", str_replace("\r", "", $pem));
149+
$pem = str_replace(["\r", "\n"], ['', ''], $pem);
150150
if ($pretty) $pem = self::prettify($pem);
151151
return $pem;
152152
}

0 commit comments

Comments
 (0)