我有两台服务器,A和B。它们都运行在相同的代码库上,并在带有 apache2 的 debian 上运行。
我需要安全且定期地检查来自服务器 A 和服务器 B 的 REST 响应。
我构建了一个简单的 cURL 脚本,以使用基本身份验证从服务器 B 连接到服务器 A:
<?php
$url = 'http://mydomain/restpath/get';
$ch = curl_init($url);
$username = 'username';
$password = 'password';
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0 );
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//set the basic auth to any then set the creds
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
此处的凭据将以明文形式传递.. 为了保护我打算使用 HTTPS 连接。
## 我对 https 证书的了解是初学者 ##
仅使用随 Apache 提供的示例中声明的 defualt 证书是否安全:
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
还是我还需要做更多的事情?
谢谢John
在写问题并意识到正确的问题应该是什么时,并且已经在这里得到了回答:
https://superuser.com/questions/700170/are-ssls-default-snake-oil-certificates-truly-snake-oil-as-opposed-to-being-gen