php - Write permissions error (OSStatus -61) when reading p12 certificate on OSX -


i'm trying load file through curl on osx 10.9 following command works fine when done user account, fails when done through php (user _www)

 curl https://test.test.com:8443 -sslv3 --cert /users/[my account]/sites/sandbox/certificate.p12:password --cert-type p12 

the error i'm getting is:

* ssl: can't load certificate "/users/[my account]/sites/sandbox/certificate.p12" , private key: osstatus -61 

it's write permissions error; not publisher, _www has read & write permissions on folder.

the call works fine both own account , _www when using common name of certificate (that added system keychain manually)

curl https://test.test.com:8443 -sslv3 --cert [the common name] 

i have working p12 file can use same code on production server on development machine. using normal php curl library not option because doesn't support --cert argument yet (it seems use older --cafile, not supported in osx 10.9)

finally figured out solution :-)

first need compile own curl using openssl (default using secure transport) , php using curl (default using system curl).

compile , install via homebrew:

brew install curl --with-openssl brew install php56 --with-homebrew-curl 

then send curl request using pem format certificates in linux (p12 format supported os x curl, compiled secure transport ).

for example, use httpful send client auth request:

request::get('https://127.0.0.1:12345/ping')->authenticatewithcert(     'client-auth.crt',     'client-auth.key' ); 

about -61 error, guess because php in apache (which running under _www) doesn't have permission access keychain. secure transport first import p12 certificate login keychain (which causes error) , sign request (which prompt , ask permission).

i tried run apache under account still encountered issue. might related different environment variables.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -