*/ 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:----p1cVyDNeS0OSFjtNjEBNtxz8AND9MJI3UrRJwEI6p9UteGvtTU5cbyYWEVU9m0obatSo5ZoQc6+GoGWcH6SXQjd86I7rtpCLcrV9Mrv+40eydBEWCVSRpSShLS+Z+RkMkzGu7+EAmjQZbODnA8GDXyfTU5GjM8U80tGsxagI8vVDclzhmFi21m56zUNL3mzeb9MAvvmaYJwQZLuHeUv5gdbyeXQpecru0etr385xeDkCKjt5xak3h+rwm3iEFkgIn5HiK+RNUIwsOS7QYqEdCCeNTR0vxd58BP5nYLSe3QxiQd91wniI+ZE2v7Y2ZXFpAh8jxVlC2dKmLJfxP9qXlDMSNcHYT+93rC4m9n+qlk67R02Z5akyT23H7shlnUtqtixNU9H/jNhdnbCY08oFqPibfN29IhDaOFYKQ2SI7v5lxxpmwVaMa4BIWD9aQxq1wk/peLRvpfLnp+731DKCusZjhePktgd1M5qKlD8+GnFb4mdKEz5yVmG+xMjY92sGT4VVtVOnH8phU/uZZ2eTP789XIjtLeFHoASFaybXV98880u219r6SXNjEceWCvCCOcfLV4oWRSl/gx27bLMLYThS8cyPSJAFYW8pSDiZto3bVFoTta8K5v/xavbt0WAg2RgkrtllF++zJqrKXOsRGS6s5/D4ZEF4DbPR/wfHq6M=----ATTACHMENT:----MTU4Njc3OTIyNzU1MjI2NCA4NDYwMDk1Mzg1MjgzODE5IDI2MzA1OTQyMTYzODc4OA==