|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-10-02 17:28 UTC] kanareykin+nospam at denison dot edu
I can't get the example openssl_seal() code (given in the online manual) to work. The function always returns FALSE without specifying an error; sealed data and envelope keys are void. I'm using the demo key and certificate that comes with OpenSSL 0.9.6a (in demos dir) and all of the other functions (like openssl_get_public_key) seem to work, i.e. they return resource identifiers. Config line: './configure' '--with-apxs=/usr/local/apache/bin/apxs' '--with-cybercash=/usr/installs/mck-3.3.1-sparc-sun-solaris2.7''--with-mysql=/usr/local' '--with-xml' '--with-oci8' '--with-curl=/usr/local''--with-openssl=/usr/local' '--with-ldap=/usr/local' PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 06:00:01 2025 UTC |
Upgraded to 4.0.6, so now I can use the openssl_error_string() function. However, I still don't see any errors generated by openssl_seal(). Below is how I use it: if (openssl_seal($data, $sealed, $ekeys, array($pk1,$pk2))) { echo "Sealed: $sealed\n"; } else { echo "Could not seal data\n"; while ($text = openssl_error_string()) echo "$text \n"; } This reports no errors. When I try to open the 'encrypted' data, I do get some errors (I think these are expected): error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02 error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failedBelow is the *whole* script. The only output I get is "There were errors". It can't seal the data, returning FALSE, but no error messages are generated. <?php $cert_path1 = "/usr/installs/openssl-0.9.6a/demos/maurice/cert.pem"; $cert_path2 = "/usr/installs/openssl-0.9.6a/demos/sign/cert.pem"; $data = "This is the data to be sealed"; $fp = fopen($cert_path1, "r"); $cert = fread($fp, 8192); fclose($fp); $pk1 = openssl_get_publickey($cert); $fp = fopen($cert_path2, "r"); $cert = fread($fp, 8192); fclose($fp); $pk2 = openssl_get_publickey($cert); if (openssl_seal($data, $sealed, $ekeys, array($pk1,$pk2))) echo "Sealed data: $sealed<br />"; else { echo "There were errors<br />"; while ($text = openssl_error_string()) echo "$text <br />"; } openssl_free_key($pk1); openssl_free_key($pk2); ?>I have exactly the same problem, with php4.3.10 / openssl OpenSSL 0.9.7e / on BSD/OS 4.2 i386 openssl_error_string return nothing, but openssl_seal returns false. This is the script: <?php function seal($info,$key){ if($pk = openssl_get_publickey($key)){ echo openssl_error_string();echo '<br>'; $res=openssl_seal($info, $sealed, $ekeys, array($pk)); echo openssl_error_string();echo '<br>'; var_dump($res);echo '<br>'; openssl_free_key($pk); return array('sealed'=>$sealed,'ekey'=>$ekeys[0]); } echo openssl_error_string();echo '<br>'; return FALSE; } $key="-----BEGIN CERTIFICATE----- MIIBdDCCAR4CAQAwDQYJKoZIhvcNAQEEBQAwRTELMAkGA1UEBhMCQVUxEzARBgNV BAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0 ZDAeFw0wNTAxMTgxOTUyMjBaFw0wNTA3MTcxOTUyMjBaMEUxCzAJBgNVBAYTAkFV MRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRz IFB0eSBMdGQwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAx7Z4soVmUJvKfhtBzKAP oRs9bdllaaTvy9I1kdf0AVFCKN7+US2LQBpGyCpTuENM+WQxJ6vGtJ2pYhGmbPm5 0QIDAQABMA0GCSqGSIb3DQEBBAUAA0EAlvwJFlCbuagfpc6XM7zY8JP0Gz+CXlbh NUjPgT8xkXzOBtjNxe+yNmhAfGyMXc7uKR+3tS6uHXzPvMg3PKCvqw== -----END CERTIFICATE----- "; print_r(seal("Secret data",$key));echo '<br>'; ?> Returns this: bool(false) Array ( [sealed] => [ekey] => ) The same script runs ok on another computer (php4.3.9/macosx)