Jump to content

openssl_pkcs7_encrypt problem


Recommended Posts

Hi all, I have php-7.4.4-Win32-vc15-x86, installed and want to use openssl_pkcs7_encrypt in order to encrypt a stream.

I prepare all input, checked all are ok, and after calling openssl_pkcs7_encrypt,

if (!openssl_pkcs7_encrypt($messageData, $encryptedMessage, $filestream, []))
	// Check OpenSSL errors
    while ($error = openssl_error_string())
        echo "OpenSSL error: $error\n";
	echo 'Encryption successful';

I get error message:

OpenSSL error: error:02001002:system library:fopen:No such file or directory
OpenSSL error: error:2006D080:BIO routines:BIO_new_file:no such file

Please note that the cert file is read using:

$certfilepath = "C:/Users/user1/testfolder/test.cer";
$filestream = file_get_contents($certfilepath);

I think something has to do with openssl environment, because everything else seems fine.

Please help.

Link to comment
Share on other sites

You want to encrypt a stream using functionality that encrypts files? That doesn't sound right...

"No such file or directory" sounds relevant. Does the $messageData file exist, and is it readable by PHP? Does the $encryptedMessage file exist, or at least its parent directory, and is it writable by PHP?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.