带自签名证书的POST请求 [英] POST request with a self-signed certificate

查看:227
本文介绍了带自签名证书的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请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆