Skip to content

Commit

Permalink
Merge pull request #24171 from owncloud/stable8.2-certificate
Browse files Browse the repository at this point in the history
[stable8.2] Ignore certificate file if it starts with file://
  • Loading branch information
DeepDiver1975 committed Apr 22, 2016
2 parents 1e017ea + d3f585c commit 05b9503
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/private/security/certificate.php
Expand Up @@ -50,6 +50,13 @@ class Certificate implements ICertificate {
public function __construct($data, $name) {
$this->name = $name;
$gmt = new \DateTimeZone('GMT');

// If string starts with "file://" ignore the certificate
$query = 'file://';
if(strtolower(substr($data, 0, strlen($query))) === $query) {
throw new \Exception('Certificate could not get parsed.');
}

$info = openssl_x509_parse($data);
if(!is_array($info)) {
throw new \Exception('Certificate could not get parsed.');
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/security/certificate.php
Expand Up @@ -50,6 +50,14 @@ public function testBogusData() {
$certificate->getIssueDate();
}

/**
* @expectedException \Exception
* @expectedExceptionMessage Certificate could not get parsed.
*/
function testCertificateStartingWithFileReference() {
new Certificate('file://'.__DIR__ . '/../../data/certificates/goodCertificate.crt', 'bar');
}

public function testGetName() {
$this->assertSame('GoodCertificate', $this->goodCertificate->getName());
$this->assertSame('BadCertificate', $this->invalidCertificate->getName());
Expand Down

0 comments on commit 05b9503

Please sign in to comment.