Skip to content

Commit 49ee913

Browse files
committed
Use composer/ca-bundle instead of system CA for element14 provider
This is a workaround for debian systems, where the required root CA is missing as trusted CA in the system CAs. This fixes issue #891 and #866
1 parent e75e0c4 commit 49ee913

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"api-platform/core": "^3.1",
1616
"beberlei/doctrineextensions": "^1.2",
1717
"brick/math": "0.12.1 as 0.11.0",
18-
"composer/ca-bundle": "^1.3",
18+
"composer/ca-bundle": "^1.5",
1919
"composer/package-versions-deprecated": "^1.11.99.5",
2020
"doctrine/data-fixtures": "^2.0.0",
2121
"doctrine/dbal": "^4.0.0",

composer.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Services/InfoProviderSystem/Providers/Element14Provider.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
3030
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
3131
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
32+
use Composer\CaBundle\CaBundle;
3233
use Symfony\Contracts\HttpClient\HttpClientInterface;
3334

3435
class Element14Provider implements InfoProviderInterface
@@ -43,9 +44,19 @@ class Element14Provider implements InfoProviderInterface
4344
private const COMPLIANCE_ATTRIBUTES = ['euEccn', 'hazardous', 'MSL', 'productTraceability', 'rohsCompliant',
4445
'rohsPhthalatesCompliant', 'SVHC', 'tariffCode', 'usEccn', 'hazardCode'];
4546

46-
public function __construct(private readonly HttpClientInterface $element14Client, private readonly string $api_key, private readonly string $store_id)
47-
{
47+
private readonly HttpClientInterface $element14Client;
4848

49+
public function __construct(HttpClientInterface $element14Client, private readonly string $api_key, private readonly string $store_id)
50+
{
51+
/* We use the mozilla CA from the composer ca bundle directly, as some debian systems seems to have problems
52+
* with the SSL.COM CA, element14 uses. See https://github.com/Part-DB/Part-DB-server/issues/866
53+
*
54+
* This is a workaround until the issue is resolved in debian (or never).
55+
* As this only affects this provider, this should have no negative impact and the CA bundle is still secure.
56+
*/
57+
$this->element14Client = $element14Client->withOptions([
58+
'cafile' => CaBundle::getBundledCaBundlePath(),
59+
]);
4960
}
5061

5162
public function getProviderInfo(): array

0 commit comments

Comments
 (0)