请求时出现非 ACME 400 HTTP 错误
A non-ACME 400 HTTP error occured on request
尝试将 acmephp 库集成到我的项目中,但是当我尝试请求域授权时,我一直收到此错误
A non-ACME 400 HTTP error occured on request "POST https://acme-v02.api.letsencrypt.org/acme/new-order" (response body: "(truncated...)")
这是客户端初始化代码
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');
尝试将 acmephp 库集成到我的项目中,但是当我尝试请求域授权时,我一直收到此错误
A non-ACME 400 HTTP error occured on request "POST https://acme-v02.api.letsencrypt.org/acme/new-order" (response body: "(truncated...)")
这是客户端初始化代码
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');