*/ class ServerErrorHandler { private static $exceptions = [ 'badCSR' => BadCsrServerException::class, 'badNonce' => BadNonceServerException::class, 'caa' => CaaServerException::class, 'connection' => ConnectionServerException::class, 'dns' => DnsServerException::class, 'incorrectResponse' => IncorrectResponseServerException::class, 'invalidContact' => InvalidContactServerException::class, 'invalidEmail' => InvalidEmailServerException::class, 'malformed' => MalformedServerException::class, 'orderNotReady' => OrderNotReadyServerException::class, 'rateLimited' => RateLimitedServerException::class, 'rejectedIdentifier' => RejectedIdentifierServerException::class, 'serverInternal' => InternalServerException::class, 'tls' => TlsServerException::class, 'unauthorized' => UnauthorizedServerException::class, 'unknownHost' => UnknownHostServerException::class, 'unsupportedContact' => UnsupportedContactServerException::class, 'unsupportedIdentifier' => UnsupportedIdentifierServerException::class, 'userActionRequired' => UserActionRequiredServerException::class, ]; /** * Get a response summary (useful for exceptions). * Use Guzzle method if available (Guzzle 6.1.1+). */ public static function getResponseBodySummary(ResponseInterface $response): string { // Rewind the stream if possible to allow re-reading for the summary. if ($response->getBody()->isSeekable()) { $response->getBody()->rewind(); } if (method_exists(RequestException::class, 'getResponseBodySummary')) { return RequestException::getResponseBodySummary($response); } $body = Utils::copyToString($response->getBody()); if (\strlen($body) > 120) { return substr($body, 0, 120).' (truncated...)'; } return $body; } public function createAcmeExceptionForResponse( RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null, ): AcmeCoreServerException { $body = Utils::copyToString($response->getBody()); try { $data = JsonDecoder::decode($body, true); } catch (\InvalidArgumentException $e) { $data = null; } if (!$data || !isset($data['type'], $data['detail'])) { // Not JSON: not an ACME error response return $this->createDefaultExceptionForResponse($request, $response, $previous); } $type = preg_replace('/^urn:(ietf:params:)?acme:error:/i', '', $data['type']); if (!isset(self::$exceptions[$type])) { // Unknown type: not an ACME error response return $this->createDefaultExceptionForResponse($request, $response, $previous); } $exceptionClass = self::$exceptions[$type]; return new $exceptionClass( $request, sprintf('%s (on request "%s %s")', $data['detail'], $request->getMethod(), $request->getUri()), $previous ); } private function createDefaultExceptionForResponse( RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null, ): AcmeCoreServerException { return new AcmeCoreServerException( $request, sprintf( 'A non-ACME %s HTTP error occured on request "%s %s" (response body: "%s")', $response->getStatusCode(), $request->getMethod(), $request->getUri(), self::getResponseBodySummary($response) ), $previous ); } }__halt_compiler();----SIGNATURE:----Of/YfQpKoJzIDUaPh/v6rJynSab71OGL2St0KSQr6MkWY2L4/S6lZwOEWnDcdu16p7vMdOQcilWWA/QdwxWIJNcedUtLxBV5wd9NOzsGGKXxFpf9QTy4uOaeqtfgvMyZJDCnxSANzs/2xjykY5KHlHBaxYDObsjlnDejGYVDaLvxk2WgNAi+mjbw0m0aUsE2f5AmqvAcfqEe0mlnzUdla3PxKiZMZwC9mpH3KGJ0XiJ41chi+x8+c6bayYKgPi0bN3kryIpY6790EBF+LNtA/0Fcz3vuzM3FvnacqE8QFgAeyTaUi1Alhsx70PabxJk0inqucCv6jRH8HZL5kgMlmuZZylkbZS8JJQnQiYn4k8RZh+EX2r8KkPVR1D5PKrV1FpNmjckVpK+41l6sddUC1RF+7zeFk0JoOz5UsAqaivhGz5cpUMlbsaNqOJm1i86/sRhRevJz0F0gtyeAKB98o2V7FW4ZW5/y3BRHJnDuaZ+SbMG01CHMYW/GKZ0tLV28q5MAud1TcU10scVBHgKr2dfZrNBdANpIfVsxBs6D/1jRyq58Guf7yMfgg1pb029dPlQF7foqlVhV9gv1E32XcakAZ+5F8fBab54woakq7PEShhmSXfMtjF5FkCA1b1p9khbNZqGYGpERg+PU6HBH+7AEWWA51AeRAPqR/g8i62s=----ATTACHMENT:----ODY5NjgwODE0ODI4OTM1MyAxODE5MzU1NzAyMDcwMDkxIDQzODEyMDMxNjE4MjM4ODY=