Answer the question
In order to leave comments, you need to log in
How to pass client certificate in PHP?
I'm trying to make authorization by self-signed certificates in my API.
I got to checking the certificate on the server and hung a little. I wanted to check certificates at the PHP level via OpenSSL, but I can't pass the necessary fastcgi_param via nginx. (there are no certificates sent by the client in $_SERVER)
I found a bunch of articles on how to check at the nginx level, but not a single one on how to simply pass certificates to PHP.
On the client side, I transfer client certificates signed by the server via curl like this:
$opts[CURLOPT_CAPATH] = '';
$opts[CURLOPT_CAINFO] = realpath(SRC_DIR .'/../etc/ssl/root_CA.crt');
$opts[CURLOPT_SSLCERT] = realpath(SRC_DIR .'/../etc/ssl/client.crt');
$opts[CURLOPT_SSLCERTPASSWD] = '';
$opts[CURLOPT_SSLKEY] = realpath(SRC_DIR .'/../etc/ssl/client.key');
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question