From e84ece1491f3fb7868992c83390236f61ddafaa6 Mon Sep 17 00:00:00 2001 From: freekmurze Date: Fri, 28 Oct 2022 15:29:19 +0000 Subject: [PATCH] Fix styling --- src/SslCertificate.php | 4 +++- tests/SslCertificateFromFileTest.php | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/SslCertificate.php b/src/SslCertificate.php index 9bf85cc..6476797 100644 --- a/src/SslCertificate.php +++ b/src/SslCertificate.php @@ -22,9 +22,10 @@ public static function createForHostName(string $url, int $timeout = 30, bool $v public static function createFromFile(string $pathToCertificate): self { $fileContents = file_get_contents($pathToCertificate); - if (!str_contains($fileContents,'BEGIN CERTIFICATE')) { + if (! str_contains($fileContents, 'BEGIN CERTIFICATE')) { $fileContents = self::der2pem($fileContents); } + return self::createFromString($fileContents); } @@ -55,6 +56,7 @@ public static function createFromArray(array $properties): self public static function der2pem($der_data): string { $pem = chunk_split(base64_encode($der_data), 64, "\n"); + return "-----BEGIN CERTIFICATE-----\n".$pem."-----END CERTIFICATE-----\n"; } diff --git a/tests/SslCertificateFromFileTest.php b/tests/SslCertificateFromFileTest.php index 980ca6b..2e46daa 100644 --- a/tests/SslCertificateFromFileTest.php +++ b/tests/SslCertificateFromFileTest.php @@ -14,14 +14,11 @@ class SslCertificateFromFileTest extends TestCase /** @var Spatie\SslCertificate\SslCertificate */ protected $certificate; - protected function setUp(): void { parent::setUp(); Carbon::setTestNow(Carbon::create('2020', '01', '13', '03', '18', '13', 'utc')); - - } /** @test */ @@ -39,5 +36,4 @@ public function it_can_load_der_certificate() $this->assertSame("Let's Encrypt", $this->certificate->getOrganization()); $this->assertSame("analytics.spatie.be", $this->certificate->getDomain()); } - }