POST request with a self-signed certificate(带有自签名证书的 POST 请求)
问题描述
我将使用 PHP 将一些数据从站点 A 发布到站点 B.站点 A 具有商业 SSL 证书.站点 B 将拥有一个自签名证书.这是可行的吗?如果没有,我可以设置 PHP(或 Apache)中的任何配置选项以绕过限制吗?
I'm going to POST some data from site A to site B using PHP. Site A has a commercial SSL certificate. Site B is going to have a self-signed certificate. Is this doable? If not, are there any configuration options in PHP (or Apache) that I can set to bypass the restrictions?
推荐答案
大概你会在服务器 A 上使用 curl?curl 中有几个选项可以禁用证书验证,这将允许自签名证书通过.该链接仍将被加密,但您将无法信任服务器 B 真的 IS 服务器 B:
Presumably you'll be using curl on server A? There's a couple options in curl to disable certificate validation, which'll allow self-signed certs through. The link will still be encrypted, but you won't be able to trust that server B really IS server B:
curlopt_ssl_verifypeer (checking the CA auth chain)
curlopt_ssl_verifyhost (hostname/certname match checks)
示例 PHP 代码:
$ch = curl_init("https://example.com/example/path");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec($ch);
这篇关于带有自签名证书的 POST 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有自签名证书的 POST 请求


- 从 PHP 中的输入表单获取日期 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Laravel 仓库 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01