*/ 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:----r1NUgCzVElr5ezF8JMZXkP7nIdNrXhO5W4ymRrWXph/TLSILixnlWLxSOeyR9++K804b4xFBg8uUdmRvmuy2KcGkGrTiY44I4xAoWHsv2PtOZw3jX8UM50yUjplC+98nNr8ZO3xd/jDbckp/JvLens74mFNaDwNLOuFWEvzGvYJ70fcVWeJm+n5rW0E2iCPRVxz1dVqdXJijYYg7WlMQwuAefm3zpM8AK+LxqmjK6rhVPoMKVOcnuaqmLX6VjVRKHOEGpkOEQX8yCafYSTr5QLMIQZqKUqEN/GhS7Ag9H5Pe3uQ6q/BLl3MPyOzB/H9XIR/tEzD6mdThkRKpxgntKmOhQHg30BrHu1XuERDWSiq2v2juH88sdo84/L4KQs2MtTAJ3egiqDjUPsjScFgVV3SyN1DQybwUOhiC+Gxtjgv+14xvEYTOzmQF9Ek75p4TetKaeb/QlKssnbVxDTGPYuX2WUuHCeUzNCci4l/YhJ+TNZNNymmsq6xmY07T1zVuhj3+tBxnyUF3dkf09gCCVhCwqktl7qXETGycNLfk7/h01FJN4w00Y3J1uKlMBfueYuXjrhjMZkhT4r2AQj1noTsmdC/GLKuuDL80329Rcxw8HpuGcyZY/fIFS9Z4VAx5BZemNDq/TkSztRr2gOFINxZkamzswcff15ogeV0nxOQ=----ATTACHMENT:----OTU0Mjc1MTQxNjgzNDQxMyAxODY1NDA2NTU5MDM0MDYwIDIxNzQ2MzMwMTA1MjE1ODQ=