lets-encrypt - 请求时发生非 ACME 400 HTTP 错误
问题描述
尝试将 acmephp 库集成到我的项目中,但是当我尝试为域请求授权时,我不断收到此错误
请求“POST https://acme-v02.api.letsencrypt.org/acme/new-order ”时出现非 ACME 400 HTTP 错误(响应正文:“(截断...)”)
这是客户端初始化代码
public function registerWebsite()
{
try {
$secureHttpClientFactory = new SecureHttpClientFactory(
new GuzzleHttpClient(),
new Base64SafeEncoder(),
new KeyParser(),
new DataSigner(),
new ServerErrorHandler()
);
$acmeKeyPath = storage_path('acme-keys');
if (!file_exists($acmeKeyPath)) {
mkdir($acmeKeyPath, 0700, true);
}
$publicKeyPath = $acmeKeyPath . '/account.pub.pem';
$privateKeyPath = $acmeKeyPath . '/account.pem';
if (!file_exists($privateKeyPath)) {
$keyPairGenerator = new KeyPairGenerator();
$keyPair = $keyPairGenerator->generateKeyPair();
file_put_contents($publicKeyPath, $keyPair->getPublicKey()->getPEM());
file_put_contents($privateKeyPath, $keyPair->getPrivateKey()->getPEM());
} else {
$publicKey = new PublicKey(file_get_contents($publicKeyPath));
$privateKey = new PrivateKey(file_get_contents($privateKeyPath));
$keyPair = new KeyPair($publicKey, $privateKey);
}
$secureHttpClient = $secureHttpClientFactory->createSecureHttpClient($keyPair);
$acmeClient = new AcmeClient($secureHttpClient, 'https://acme-staging-v02.api.letsencrypt.org/directory');
$registerResponse = $acmeClient->registerAccount(null, 'kaladakienka@gmail.com');
$authorizationChallenges = $acmeClient->requestAuthorization('http://ssl-ops-staging.thehuddle.nl/');
dd($authorizationChallenges);
} catch (\Exception $ex) {
dd($ex->getMessage());
}
}
解决方案
想通了。
$acmeClient->requestAuthorization('http://ssl-ops-staging.thehuddle.nl/')
应该
$acmeClient->requestAuthorization('ssl-ops-staging.thehuddle.nl');
推荐阅读
- java - 如何在 JPanel 上绘制图像并在其中添加组件
- c# - C# 调用 aspnet webapi 令牌端点在我的本地主机上完美运行,但在服务器上给出错误
- javascript - 我们如何在 JavaScript 中导入/包含 MathQuill?
- javascript - 表单验证错误(初学者)
- python - pypandoc | 转换多个文件
- php - PHP - 如果数组包含字符串的一部分
- vba - 使用 Find 方法从另一个工作表中搜索字符串
- c# - Sys.WebForms.PageRequestManager.getInstance() 多次调用(每次请求递增)
- selenium - 错误构建 VSTS - VSTest TASK - OpenQA.Selenium.WebDriverException:未知错误:找不到 Chrome 二进制文件
- azure - 我无法在 Azure blob 容器中更新 Intranet 站点的 html 中的元数据