diff --git a/src/PDFDoc.php b/src/PDFDoc.php index 0ad1a3b..7441b33 100644 --- a/src/PDFDoc.php +++ b/src/PDFDoc.php @@ -296,8 +296,8 @@ public function set_signature_certificate($certfile, $certpass = null) { // If a password is provided, we'll try to decode the private key if (openssl_pkey_get_private($certificate["pkey"]) === false) return p_error("invalid private key"); - - // TODO: check the certificate + if (! openssl_x509_check_private_key($certificate["cert"], $certificate["pkey"])) + return p_error("private key doesn't corresponds to certificate"); } else { $certfilecontent = file_get_contents($certfile); if ($certfilecontent === false)