ฟังกชั่น openssl_get_cert_locations สำหรับไว้หาพาร์ทของ Certificate โดยปกติเวลาเราติดตั้ง openssl ไว้ในเครื่อง php ของเราก็จะไปดึงไฟล์ Certificate นี้มาใช้เพื่อนำมันมาเป็นส่วนหนึ่งการของ PHP สำหรับฟังก์ชั่นที่เกี่ยวกับเครือข่าย พูดง่ายๆ คือ ฟังก์ชั่นของ PHP ที่มีการติดต่อสื่อสาร ส่งค่าไปมากันระหว่าง Server เช่น ฟังก์ชั่นพวก Curl socket_send() : ใช้ในการส่งข้อมูล หรือแม้แต่การส่งเมลด้วย SMTP โดยปกติ ค่านี้จะถูกกำหนดไว้ที่ php.ini
แยกสองตัวคือ
openssl.cafile
openssl.capath
เราสามารถดึงค่านี้มาใช้ได้ด้วย ฟังก์ชั่น นี้
รูปแบบฟังก์ชั่น
openssl_get_cert_locations(): array
ตัวอย่างเช่น
<?php
var_dump(openssl_get_cert_locations());
?>
ตัวอย่างผลที่ได้
array(8) {
["default_cert_file"]=>
string(48) "C:\Program Files (x86)\Common Files\SSL/cert.pem"
["default_cert_file_env"]=>
string(13) "SSL_CERT_FILE"
["default_cert_dir"]=>
string(45) "C:\Program Files (x86)\Common Files\SSL/certs"
["default_cert_dir_env"]=>
string(12) "SSL_CERT_DIR"
["default_private_dir"]=>
string(47) "C:\Program Files (x86)\Common Files\SSL/private"
["default_default_cert_area"]=>
string(39) "C:\Program Files (x86)\Common Files\SSL"
["ini_cafile"]=>
string(38) "D:\xampp\apache\bin\curl-ca-bundle.crt"
["ini_capath"]=>
string(0) ""
}
ถ้าค่าที่ดึงมาไม่ตรงหรือติดตั้ง OpenSSL ไว้ผิดเวอร์ชั่น บางทีอาจเจอปัญหาตามนี้ได้ ปัญหาส่งเมล ด้วย PHP ผ่าน SMTP ไม่ได้