Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and github-actions[bot] committed Oct 28, 2022
1 parent 69a61d2 commit e84ece1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/SslCertificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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";
}

Expand Down
4 changes: 0 additions & 4 deletions tests/SslCertificateFromFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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());
}

}

0 comments on commit e84ece1

Please sign in to comment.