[nycphp-talk] Working with openssl
Rob Marscher
rmarscher at beaffinitive.com
Thu Aug 17 13:53:38 EDT 2006
Here's how I got openssl_get_privatekey() to work:
$private_key = array("file://" . $path, $passphrase);
$private = openssl_get_privatekey($private_key);
Hope that helps.
-Rob
csnyder wrote:
> On 8/17/06, Aaron Fischer <agfische at email.smith.edu> wrote:
>> I've been reading and am trying to work with the openssl code example
>> given in Pro PHP Security. It works smoothly when I run the demo code
>> on my server which generates a public and private key and encrypts and
>> decrypts a small bit of text.
>>
>> However I run into errors when trying to test it in a manner that starts
>> to simulate a production environment.
>>
>> How I'm testing:
>> 1. Run the openssl demo code, which creates a public and private key
>> and encrypts a small amount of text.
>> 2. On a separate page I have created a form that I use to copy and
>> paste the private key, encrypted text and passphrase.
>> 3. Post the form which is coded to create a new openssl object and pass
>> it the private key and attempt to decrypt. This produces errors:
>>
>> Warning: openssl_private_decrypt() [function.openssl-private-decrypt]:
>> key parameter is not a valid private key in
>> /home/a/adm1a/openSSL/openSSL.php on line 119
>>
>> Warning: openssl_free_key() expects parameter 1 to be resource, null
>> given in /home/a/adm1a/openSSL/openSSL.php on line 122
>> Testing OpenSSL
>>
>> Here are the testing pages:
>>
>> OpenSSL Demo
>> http://www.smith.edu/admission/openSSL/openSSLdemo.php
>> Form testing page (passphrase is 'Encryption is fun for everyone')
>> http://www.smith.edu/admission/openSSL/openSSLtest.php
>>
>> Here is the actual code:
>> OpenSSL class
>> http://www.smith.edu/admission/openSSL/openSSLCode.php
>> Demo code
>> http://www.smith.edu/admission/openSSL/openSSLdemoCode.php
>> Form page for testing
>> http://www.smith.edu/admission/openSSL/openSSLtestCode.php
>>
>> Thoughts or suggestions? Much appreciated.
>>
>> -Aaron
>>
>> _______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>>
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
>>
>
> Hi Aaron --
>
> Nothing jumps out immediately, but to help debug the problem you
> should probably try with an unecrypted private key at first.
> openssl_get_privatekey() returns that invalid key error if it can't
> decypt the key for some reason.
>
More information about the talk
mailing list