I have researched from google but can not fix. is it package's error ?. pleas help me. Error in $client->getCertificate($order)); function
Closed this issue · 1 comments
JobirYusupov commented
class TestAcme2Controller extends ZControlCmd
{
public function file_force_contents( $fullPath, $contents, $flags = 0 ){
$parts = explode( '/', $fullPath );
array_pop( $parts );
$dir = implode( '/', $parts );
if( !is_dir( $dir ) )
mkdir( $dir, 0777, true );
file_put_contents( $fullPath, $contents, $flags );
}
public function actionRun()
{
//Prepare flysystem
$adapter = new Local('data');
$filesystem = new Filesystem($adapter);
//Construct the client
$client = new Client([
'username' => 'jobiryusupov0@gmail.com',
'fs' => $filesystem,
'mode' => Client::MODE_STAGING,
]);
$order = $client->createOrder(['vadeacme.zoft.uz']);
$authorizations = $client->authorize($order);
foreach ($authorizations as $authorization) {
$file = $authorization->getFile();
file_put_contents($file->getFilename(), $file->getContents());
$this->file_force_contents( Root.'/execut/web/eyuf/.well-known/acme-challenge/'.$file->getFilename(), $file->getContents(), LOCK_EX );
}
if (!$client->selfTest($authorization, Client::VALIDATION_HTTP)) {
throw new \Exception('Count not verify ownership via HTTP');
}
foreach ($authorizations as $authorization) {
$client->validate($authorization->getHttpChallenge(), 15);
}
if ($client->isReady($order)) {
$certificate = $client->getCertificate($order); //error here
file_put_contents('certificate.cert', $certificate->getCertificate());
$this->file_force_contents( Root.'/execut/web/eyuf/.well-known/acme-challenge/private.key', $certificate->getPrivateKey(), LOCK_EX );
}
}
}
error:
Exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST https://acme-staging-v02.api.letsencrypt.org/acme/finalize/13081845/84000364 resulted in a 400 Bad Request response:
{
"type": "urn:ietf:params:acme:error:malformed",
"detail": "Error parsing certificate request: asn1: syntax error: (truncated...)
'
bakkerpeter commented
@JobirYusupov closing this as it is a duplicate of #8. Please do not crosspost.