Skip to content

Remove X5C EOL #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
* text=auto

/.github export-ignore
/packs export-ignore
/performance export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/.gitsplit.yml export-ignore
/CODE_OF_CONDUCT.md export-ignore
/ecs.php export-ignore
/infection.json export-ignore
/Makefile export-ignore
/phpbench.json export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
/rector.php export-ignore
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
.phpbench
.phpunit.result.cache
.travis/phar-private.pem
jose.phar
jose.phar.pubkey
jose.phar.version
.travis/build-key.pem
.travis/secrets.tar
report.md
composer.lock
.php_cs
.php_cs.cache
vendor/
src/Bundle/JoseFramework/var/
infection.txt
4 changes: 1 addition & 3 deletions .gitsplit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,4 @@ splits:
target: "https://${GH_TOKEN}@github.com/web-token/signature-pack.git"

origins:
- ^master$
- ^v\d+\.\d+$
- ^v\d+\.\d+\.\d+.*$
- ^\d+\.\d+\.\d+.*$
15 changes: 15 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Security Policy

## Supported Versions

| Version | Supported |
|---------|--------------------|
| 4.0.x | :white_check_mark: |
| 3.1.x | :white_check_mark: |
| 3.0.x | :white_check_mark: |
| < 3.0.0 | :x: |

## Reporting a Vulnerability

If you think you have found a security issue, DO NOT open an issue. You MUST email your issue: security AT
spomky-labs.com.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^8.0|^9.0",
"phpunit/phpunit": "^9.5.5",
"rector/rector": "^0.14",
"roave/security-advisories": "dev-latest",
"symfony/browser-kit": "^5.4|^6.0",
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ parameters:
- '#Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null\, mixed given\.#'
- '#Parameter \#1 \.\.\.\$arrays of function array_merge expects array\, mixed given\.#'
- '#Cannot cast mixed to int\.#'
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- '#Parameter .* of (static )?method .* expects Jose\\Component\\Core\\JWK, mixed given\.#'
- '#Cannot call method (get|has)\(\) on mixed\.#'
2 changes: 1 addition & 1 deletion src/Component/KeyManagement/KeyConverter/KeyConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function loadKeyFromX509Resource(OpenSSLCertificate $res): array
$values = self::loadKeyFromPEM($details['key']);
openssl_x509_export($res, $out);
$x5c = preg_replace('#-.*-#', '', $out);
$x5c = preg_replace('~\R~', PHP_EOL, $x5c);
$x5c = preg_replace('~\R~', '', $x5c);
if (! is_string($x5c)) {
throw new InvalidArgumentException('Unable to load the certificate');
}
Expand Down
13 changes: 7 additions & 6 deletions src/Ecc/Curve.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ public function mul(Point $one, BigInteger $n): Point

public function cmp(self $other): int
{
$equal = $this->getA()
->isEqualTo($other->getA())
&& $this->getB()
->isEqualTo($other->getB())
&& $this->getPrime()
->isEqualTo($other->getPrime());
$equalsA = $this->getA()
->isEqualTo($other->getA());
$equalsB = $this->getB()
->isEqualTo($other->getB());
$equalsPrime = $this->getPrime()
->isEqualTo($other->getPrime());
$equal = $equalsA && $equalsB && $equalsPrime;

return $equal ? 0 : 1;
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Bundle/JoseFramework/config/config_test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
framework:
test: ~
secret: 'test'
session: ~
session:
handler_id: null
storage_factory_id: 'session.storage.factory.mock_file'
router:
resource: "%kernel.project_dir%/tests/Bundle/JoseFramework/config/routing.yml"
strict_requirements: ~
Expand Down
37 changes: 18 additions & 19 deletions tests/Component/KeyManagement/CertificateTest.php

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions tests/Component/KeyManagement/JWKFactoryTest.php

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions tests/Component/KeyManagement/JWKTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Jose\Component\KeyManagement\JWKFactory;
use const JSON_THROW_ON_ERROR;
use ParagonIE\ConstantTime\Base64UrlSafe;
use const PHP_EOL;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -234,7 +233,7 @@ public function loadCertificateChain(): void
'x5t#256' => 'pBJP2vnKx7ruHKsy4yJddGUAwJ888-uyU-8_uwiK_TQ',
'kid' => 'From www.google.com',
'x5c' => [
'MIID8DCCAtigAwIBAgIDAjqDMA0GCSqGSIb3DQEBCwUAMEIxCzAJBgNVBAYTAlVT' . PHP_EOL . 'MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i' . PHP_EOL . 'YWwgQ0EwHhcNMTMwNDA1MTUxNTU2WhcNMTYxMjMxMjM1OTU5WjBJMQswCQYDVQQG' . PHP_EOL . 'EwJVUzETMBEGA1UEChMKR29vZ2xlI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