summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2016-04-21 18:52:19 +0200
committerLukas Reschke <lukas@owncloud.com>2016-04-21 18:53:00 +0200
commit9cdb8817258e62917c78765efc127247eb181b87 (patch)
tree8740a417727db2e96fa5a5814260ed0b96130951
parentb9eb25abba7f4fbbe3cb0aea8bc4e950d861a244 (diff)
downloadnextcloud-server-9cdb8817258e62917c78765efc127247eb181b87.tar.gz
nextcloud-server-9cdb8817258e62917c78765efc127247eb181b87.zip
[stable8] Ignore certificate file if it starts with file://
-rw-r--r--lib/private/security/certificate.php7
-rw-r--r--tests/lib/security/certificate.php8
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/private/security/certificate.php b/lib/private/security/certificate.php
index 58563550f81..c957a2a6a00 100644
--- a/lib/private/security/certificate.php
+++ b/lib/private/security/certificate.php
@@ -34,6 +34,13 @@ class Certificate implements ICertificate {
*/
public function __construct($data, $name) {
$this->name = $name;
+
+ // 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.');
+ }
+
try {
$gmt = new \DateTimeZone('GMT');
$info = openssl_x509_parse($data);
diff --git a/tests/lib/security/certificate.php b/tests/lib/security/certificate.php
index 4caacf900e7..e59f06db5c4 100644
--- a/tests/lib/security/certificate.php
+++ b/tests/lib/security/certificate.php
@@ -36,6 +36,14 @@ class CertificateTest extends \Test\TestCase {
new Certificate('foo', 'bar');
}
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Certificate could not get parsed.
+ */
+ function testCertificateStartingWithFileReference() {
+ new Certificate('file://'.__DIR__ . '/../../data/certificates/goodCertificate.crt', 'bar');
+ }
+
function testGetName() {
$this->assertSame('GoodCertificate', $this->goodCertificate->getName());
$this->assertSame('BadCertificate', $this->invalidCertificate->getName());