Write permission error (OSStatus -61) when reading p12 certificate in OSX

I am trying to upload a file via cURL on OSX 10.9. The following command works fine when executed from my user account, but not executed when executed 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 am getting is:

* SSL: Can't load the certificate "/Users/[my account]/Sites/sandbox/certificate.p12" and its private key: OSStatus -61

This is an error writing permissions; Not a publisher , but you have read and write permissions to the folder.

The call works fine with both my own account and when using the common certificate name (which I manually added to my system keychain)

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

I would like it to work with the p12 file, so I can use the same code on the production server as on my development machine. Using the regular php cURL library is not an option because it does not yet support the argument --cert(it seems to use an older --cafileone that is not supported in OSX 10.9)

+4
source share
1 answer

Finally, a solution was found :-)

First you need to compile your own curl using OpenSSL (Secure Transport by default) and PHP using this curl (default system curl).

Compile and install via Homebrew:

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

curl, PEM, Linux ( P12 OS X, Secure Transport).

, HTTPful :

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

-61, , , PHP Apache ( _www) . Secure Transport P12 ( ), ( ).

Apache , . .

+2

Source: https://habr.com/ru/post/1530999/


All Articles