*/ 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+). * * @return string */ public static function getResponseBodySummary(ResponseInterface $response) { // 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 = \GuzzleHttp\Psr7\copy_to_string($response->getBody()); if (\strlen($body) > 120) { return substr($body, 0, 120).' (truncated...)'; } return $body; } /** * @return AcmeCoreServerException */ public function createAcmeExceptionForResponse( RequestInterface $request, ResponseInterface $response, \Exception $previous = null, ) { $body = \GuzzleHttp\Psr7\copy_to_string($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 ); } /** * @return AcmeCoreServerException */ private function createDefaultExceptionForResponse( RequestInterface $request, ResponseInterface $response, \Exception $previous = null, ) { 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:----KGPGCNCPKB6Hs+vzx0EUtxDeBfH2y+gs+PXaFhT6Dnr34PS8vpn10L8Y1ovKT7ddCi5SQRG0tajdOu0HeNJ0I6gRknWvJuxUjveViAAE55Fhdd1PpPpohSXfiXbO1yfeooS86oVc/W0MeCzpVnsRdtemz0eF77ek9rNq512+57G/fErNZwV3hbwxIwFMYl1WO0HiObI/4ilPwL9e8iW7dkkKRP7urLvOLfp5PHvnXue9FqUqAQG0GZUwiqAelRwwBJ/+wsK5gtUqtyTnFfzhZETM4xJVAZnjIXJSXoRljlSKIXsqwlddt4hcYNyuJ4Ob/FaTMHZG9WwFMftNrIyL8Uk2GoDizSEXXQGTYmZrUPN4H3Xv/Jiy/deYGQ0e8DuT9JYk33//1PkoEFqrtgHeapJi6l+YDc4REm9DmXPFW9NJghz1J+IyzHXDxtGmgfHJVpvewzbEgWgiOPN5ZdJBxn0A1Pn2H8VI3tn07LJR6C1JZNyD9KCTSKoR5tdUt7Plxl0u0fnENnDAiCbO3XQ+2uR9NvbcV+PIhL6ZOB+zrvZ/ZVDdGnatgoZdowJBvq/lm0TY4hlINu9c1TT5qabPH9ztVgHhI6i6qULuBunFQ3mpBowkynLJvzbVKsen0FFC28R0acXAjXrz4omHVmU4p4O+M3rztJaUvZmLkNCW460=----ATTACHMENT:----MjIwNjQzNTU4ODg0MTMwMCA5OTkxMDA3NDE1MTY4OTQxIDYyOTQwNDIwMjUyMjAzMzg=