Skip to content
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

Add method to get signing Algorithm #10

Merged
merged 1 commit into from Aug 20, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Add method to get signing Algorithm

Added method and tests for getting an SSL's signing alogorithm
Update readme as well
And ensure I'm doing PSR2 right
  • Loading branch information
mallardduck committed Aug 19, 2016
commit e326e38b071e65fcc65dcfa9c4f7694b4f10d4e5
@@ -66,6 +66,14 @@ Returns the primary domain name for the certificate
$certificate->getDomain(); // returns "spatie.be"
```

### Getting the certificate's signing algorithm

Returns the algorithm used for signing the certificate

```php
$certificate->getSignatureAlgorithm(); // returns "RSA-SHA256"
```

### Getting the additional domain names

A certificate can cover multiple (sub)domains. Here's how to get them.
@@ -24,7 +24,8 @@ public static function downloadCertificateFromUrl(string $url, int $timeout = 30
$errorDescription,
$timeout,
STREAM_CLIENT_CONNECT,
$streamContext);
$streamContext
);
} catch (Throwable $thrown) {
if (str_contains($thrown->getMessage(), 'getaddrinfo failed')) {
throw CouldNotDownloadCertificate::hostDoesNotExist($hostName);
@@ -36,6 +36,11 @@ public function getDomain(): string
return $this->rawCertificateFields['subject']['CN'] ?? '';
}

public function getSignatureAlgorithm(): string
{
return $this->rawCertificateFields['signatureTypeSN'] ?? '';
}

public function getAdditionalDomains(): array
{
$additionalDomains = explode(', ', $this->rawCertificateFields['extensions']['subjectAltName'] ?? '');
@@ -34,6 +34,12 @@ public function it_can_determine_the_domain()
$this->assertSame('spatie.be', $this->certificate->getDomain());
}

/** @test */
public function it_can_determine_the_alogorithm()
{
$this->assertSame('RSA-SHA256', $this->certificate->getSignatureAlgorithm());
}

/** @test */
public function it_can_determine_the_additional_domains()
{
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.