diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3975a591f..6a94c4c5c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -18,9 +18,6 @@ ], 'self_accessor' => false, 'modernize_strpos' => false, - 'nullable_type_declaration_for_default_null_value' => [ - 'use_nullable_type_declaration' => true, - ], 'no_superfluous_phpdoc_tags' => [ 'allow_mixed' => true, ], @@ -33,6 +30,10 @@ 'method' => 'multi', 'property' => 'multi', ], + 'trailing_comma_in_multiline' => [ + 'after_heredoc' => false, + 'elements' => ['arrays'], + ], ]) ->setRiskyAllowed(true) ->setFinder( diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e981a4f43..e3c69ed59 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -125,6 +125,11 @@ parameters: count: 1 path: src/Options.php + - + message: "#^Method Sentry\\\\Options\\:\\:getHttpSslNativeCa\\(\\) should return bool but returns mixed\\.$#" + count: 1 + path: src/Options.php + - message: "#^Method Sentry\\\\Options\\:\\:getHttpSslVerifyPeer\\(\\) should return bool but returns mixed\\.$#" count: 1 diff --git a/src/HttpClient/HttpClient.php b/src/HttpClient/HttpClient.php index a5c64847c..e94452a14 100644 --- a/src/HttpClient/HttpClient.php +++ b/src/HttpClient/HttpClient.php @@ -78,6 +78,17 @@ public function sendRequest(Request $request, Options $options): Response curl_setopt($curlHandle, \CURLOPT_SSL_VERIFYPEER, false); } + $httpSslNativeCa = $options->getHttpSslNativeCa(); + if ($httpSslNativeCa) { + if ( + \defined('CURLSSLOPT_NATIVE_CA') + && isset(curl_version()['version']) + && version_compare(curl_version()['version'], '7.71', '>=') + ) { + curl_setopt($curlHandle, \CURLOPT_SSL_OPTIONS, \CURLSSLOPT_NATIVE_CA); + } + } + $httpProxy = $options->getHttpProxy(); if ($httpProxy !== null) { curl_setopt($curlHandle, \CURLOPT_PROXY, $httpProxy); diff --git a/src/Logger/DebugFileLogger.php b/src/Logger/DebugFileLogger.php index abee3948d..4875baa75 100644 --- a/src/Logger/DebugFileLogger.php +++ b/src/Logger/DebugFileLogger.php @@ -19,8 +19,9 @@ public function __construct(string $filePath) } /** - * @param mixed $level - * @param mixed[] $context + * @param mixed $level + * @param string|\Stringable $message + * @param mixed[] $context */ public function log($level, $message, array $context = []): void { diff --git a/src/Logger/DebugStdOutLogger.php b/src/Logger/DebugStdOutLogger.php index d83ee31ca..5b2da8faf 100644 --- a/src/Logger/DebugStdOutLogger.php +++ b/src/Logger/DebugStdOutLogger.php @@ -9,8 +9,9 @@ class DebugStdOutLogger extends AbstractLogger { /** - * @param mixed $level - * @param mixed[] $context + * @param mixed $level + * @param string|\Stringable $message + * @param mixed[] $context */ public function log($level, $message, array $context = []): void { diff --git a/src/Options.php b/src/Options.php index fe5b38103..34ebd5a7c 100644 --- a/src/Options.php +++ b/src/Options.php @@ -942,6 +942,20 @@ public function setHttpSslVerifyPeer(bool $httpSslVerifyPeer): self return $this; } + public function getHttpSslNativeCa(): bool + { + return $this->options['http_ssl_native_ca']; + } + + public function setHttpSslNativeCa(bool $httpSslNativeCa): self + { + $options = array_merge($this->options, ['http_ssl_native_ca' => $httpSslNativeCa]); + + $this->options = $this->resolver->resolve($options); + + return $this; + } + /** * Returns whether the requests should be compressed using GZIP or not. */ @@ -1139,6 +1153,7 @@ private function configureOptions(OptionsResolver $resolver): void 'http_connect_timeout' => self::DEFAULT_HTTP_CONNECT_TIMEOUT, 'http_timeout' => self::DEFAULT_HTTP_TIMEOUT, 'http_ssl_verify_peer' => true, + 'http_ssl_native_ca' => false, 'http_compression' => true, 'capture_silenced_errors' => false, 'max_request_body_size' => 'medium', diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php index 9347272f2..ddae2f913 100644 --- a/tests/OptionsTest.php +++ b/tests/OptionsTest.php @@ -362,6 +362,13 @@ static function (): void {}, 'setHttpSslVerifyPeer', ]; + yield [ + 'http_ssl_native_ca', + true, + 'getHttpSslNativeCa', + 'setHttpSslNativeCa', + ]; + yield [ 'http_compression', false,