*/ 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:----mUEl48zjGYHiq5o4TvnncU/ACN/EFWMsUPhtZfp/nufi5aBwQLcc4uvVRNX39MypndszORda9OdcQkZ4Q6FbuURhy6FKC3Y2OvQ8LktwAB2Z3DsdxBc9x6Qg/NMTSRaq6mUKN+vIdTCX+44+xh1AhrQjctrBgoqNreReUkhN5tkeQGgEK9rBOpZaltN1jo8bqagiW2zE/tVYNRUF3HB1e6WPkXkFmQEhSm0hsCEH5xY56LveyRn02Zg3qxHL3Cvh8ND1PKMPOVF8rvAHxlAlXHAciNZSax93rzpctOK84IB6V/QaPbpBOGXKyDbTY5oaRKLsaocueri6N7Wn485R6bI0JXUApiXr3eG+2JWVWPitL1rQ/s5BU/pH1yt4UQJyTjUSa7pZDgJcruXdbBESg1TRj4MchhzFqyiznZdLpJqOKoIOW0s/AAWOMDEGvY7hzqT2CuB75g88NiX34tMkZsddKE/6ACNvIEgcMB1ftMz91pXO9qdtDhCcMp+kEZuKJA2vwao+ObwAVcq6QEuzeDCFi9Cm4GZ6lLafrRIZiTvy3xGyWQemvWmZdPACaCUp598tV5MFnkezBeHecCeHkzfOQmYFys0fYE0WY8z1gdItWwsEA57dJwJyTIqNQbzgJEMPqdq6sy0P8Io+Yfu60FBYbaYzJ54CUGEVawNor64=----ATTACHMENT:----MzA0OTIxNDg5MDgwOTM4MyA1NzIxMDE0MDg2NTYwNzc1IDk2ODEwNzkwNzQzNjk1MDA=