I have encrypted a file thanks to OpenSSL with the following command:
openssl smime -encrypt -in myfile.xml -out myfile.p7m -outform DER -binary publicKey.pem
Now, I would to decrypt the file "myfile.p7m" with PHP. Currently, I'm using this code but without success:
$output = "myfile.xml";
$crt = file_get_contents("mycert.crt");
$private = openssl_pkey_get_private (file_get_contents("privateKey.pem"), "password");
openssl_pkcs7_decrypt ("myfile.p7m", $output, $crt, $private);
while($error = openssl_error_string()){
echo $error.'<br />'.PHP_EOL;
}
At this moment, I get this error:
error:2006D080:BIO routines:BIO_new_file:no such file
I have no idea what this mean.
Can you help me?
PS: I have already decrypted this file with success by using an OpenSSL command:
openssl smime -decrypt -in myfile.p7m -out myfile.xml -inkey
privateKey.pem -inform DER -passin pass:password
Edit:
Follow the advice of Vladimir Kunschikov, I've used full path for the files. I've replaced "myfile.xml" by "file://c:/wamp/www/test/myfile.xml" and "myfile.p7m" by "file://c:/wamp/www/test/myfile.p7m". Now, I have two another errors:
error:0200107B:system library:fopen:Unknown error
error:2006D002:BIO routines:BIO_new_file:system lib
Edit 2
Thank you Giovani for your response. I replace all paths as you have directed. Now, a new error is appeared!
error:0D0D20CC:asn1 encoding routines:SMIME_read_ASN1:no content type