我拥有 2 个网站,example.com 和 domain.com。两个 DNS 均托管在 Cloudflare 上。 Cloudflare 在其仪表板上提供免费的 SSL/TLS 加密。这两个网站都设置为强制 HTTPS 重写的完全加密模式。 example.com 托管在 WebHostingA 上,domain.com 托管在 HosterB 上。
我想使用domain.com从example.com/test.php获取内容。
代码:domain.com/get-contents.php
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://example.com/test.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, TRUE); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, ['username' => 'Bob']); $response = curl_exec($ch); var_dump($response);
代码:example.com/test.php
if (isset($_POST['username']) && ctype_alpha($_POST['username'])) {
echo($_POST['username'] . " You got my contents!");
} else {
echo("Nope!");
}
我能够成功返回从 example.com/test.php 获取内容(Bob 你得到了我的内容!)。然而,我担心的是我不必在 cURL 代码中提供任何类型的证书。如何检查从 domain.com 发送的内容是否已加密以及从 example.com 收到的内容是否已加密?我的目标是在这两个网站之间安全地传输数据。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号