I have a self signed signature which contains the certificate itself and the private key. My purpose is to check if this private key matches with the certificate. What I do is the following:
$private = openssl_pkey_get_private("path/to/certificate");
$public = openssl_pkey_get_public("path/to/certificate");
openssl_sign("path/to/certificate", $sig, $private);
So I create the signature based on the private and the public keys from the file. So what I need to do is to compare this signature with the existing signature in the certificate. If they match, it means that the private key matches. However, I couldn't retrieve the existing signature information from the file. I was wondering if my way is a right way to do it since I have found no information on google.
thanks.