diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-04-22 09:28:07 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-04-22 09:28:07 +0200 |
commit | 7be1094ba5bdfedb15489b45ed4f561b2590fe6a (patch) | |
tree | 763f4ff8a29130e80980b9e3d7445ca9e588a10e | |
parent | 788005fd0c6360a0de5292a9cc846ad6bd36968e (diff) | |
parent | 06a4da43ec9c17f47576e6376de7eb8797b343c6 (diff) | |
download | nextcloud-server-7be1094ba5bdfedb15489b45ed4f561b2590fe6a.tar.gz nextcloud-server-7be1094ba5bdfedb15489b45ed4f561b2590fe6a.zip |
Merge pull request #24173 from owncloud/master-certificate
[master] Ignore certificate file if it starts with file://
-rw-r--r-- | lib/private/Security/Certificate.php | 7 | ||||
-rw-r--r-- | tests/lib/security/certificate.php | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/private/Security/Certificate.php b/lib/private/Security/Certificate.php index 54486ff51fe..9aca278174e 100644 --- a/lib/private/Security/Certificate.php +++ b/lib/private/Security/Certificate.php @@ -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.'); diff --git a/tests/lib/security/certificate.php b/tests/lib/security/certificate.php index 81d159ebd52..82e91c71733 100644 --- a/tests/lib/security/certificate.php +++ b/tests/lib/security/certificate.php @@ -50,6 +50,14 @@ class CertificateTest extends \Test\TestCase { $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()); |