php - How do I keep my cacert.pem current for security reasons when using curl? -
i keep root certificates current use curl , php's internal curl
command, there no parameter download current file requires proper secure connection , keep current.
and example of using curl
in php secure connection requires file named cacert.pem
(pem encoded certificate chain validating remote connections) follows :
$ch = curl_init(); curl_setopt($ch, curlopt_url, "https://www.google.com"); curl_setopt($ch, curlopt_connecttimeout, 15); curl_setopt($ch, curlopt_timeout, 15); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 1); curl_setopt($ch, curlopt_cainfo, "pathto/cacert.pem"); curl_setopt($ch, curlopt_sslversion, curl_sslversion_tlsv1_2); if (!($data = curl_exec($ch))) { echo "no data received"; } else { echo strlen($data) + " total byte(s)"; } curl_close($ch);
while people set curlopt_ssl_verifypeer
false, , ignore problem, which bad . can see here certificate authority shows if not have file current, way connect secure server disable certificate checking , further warns of implications behind disabling peer verification.
what requesting legitimate way maintain local copy of cacert.pem
when use curl
in php communicate other servers, can continue securely .
this not request external resource or off-site link etc, due nature of problem, may way resolve require continuous updating certificate chains revoked. date, there no way obtain file either part of distribution of curl itself, or php, or curl library php , continue maintain it. while discouraging not simple update command curl --update-root-ca
nice, not exist in form.
since writing article, (and rewrite), able resolve own problem including links directly only legitimate source maintain file provided on site maintained author of curl
@ this location
further technology advancing question has been updated show how use curl
in php , force tls v1.2 connection (something transaction providers require or recommend , may not supply information on how this).
regarding certificate authorities, there few key root authorities such :
- symantec
- rapidssl
- thawte
- geotrust
- comodo
as other authorities nature such as
- microsoft
- mozilla
which can frame looking maintain own cacert.pem. keep in mind need download revocation lists (certificates have been breached or expired) respective crl's maintain proper trust mechanism, while should able away downloading root certificate chains , using local authorative file cacert.pem.
Comments
Post a Comment