PHP curl 略過檢查自簽 SSL 憑證有效性
PHP curl 略過檢查自簽 SSL 憑證有效性
資料來源: https://www.phpini.com/linux/curl-ignore-ssl-verification
<?php $url = "https://localhost/"; $post_data['var1'] = "123"; $post_data['var2'] = "abc"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); // 這裡略過檢查 SSL 憑證有效性 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); $output = curl_exec($ch); curl_close($ch); ?>
~~~~~~~~~~~~~~~
curl 略過檢查自簽 SSL 憑證有效性 (SSL/TLS)
資料來源:https://www.opencli.com/linux/curl-ignore-ssl-verification
命令模式:
curl -k https://localhost/ curl --insecure https://localhost/
PHP模式:
<?php $url = "https://localhost/"; $post_data['var1'] = "123"; $post_data['var2'] = "abc"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); // 這裡略過檢查 SSL 憑證有效性 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); $output = curl_exec($ch); curl_close($ch); ?>