Skip to content

Commit

Permalink
Merge pull request #49 from erikn69/patch-4
Browse files Browse the repository at this point in the history
Fix private key bug on windows
  • Loading branch information
dealfonso authored May 30, 2023
2 parents 3d7f18a + 982341f commit 9710a24
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/PDFDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,12 @@ public function set_signature_certificate($certfile, $certpass = null) {
// First we read the certificate
if (is_array($certfile)) {
$certificate = $certfile;
$certificate["pkey"] = [$certificate["pkey"], $certpass];

// If a password is provided, we'll try to decode the private key
$t_pkey = openssl_pkey_get_private($certificate["pkey"], $certpass);
if ($t_pkey === false)
if (openssl_pkey_get_private($certificate["pkey"]) === false)
return p_error("invalid private key");

openssl_pkey_export($t_pkey, $t_decpkey);
$certificate["pkey"] = $t_decpkey;

// TODO: check the certificate
} else {
$certfilecontent = file_get_contents($certfile);
Expand Down

0 comments on commit 9710a24

Please sign in to comment.