Merge pull request #24172 from owncloud/stable9-certificate

[stable9] Ignore certificate file if it starts with file://
This commit is contained in:
Thomas Müller 2016-04-22 09:36:32 +02:00
commit 81b5df3236
2 changed files with 15 additions and 0 deletions

View File

@ -50,6 +50,13 @@ class Certificate implements ICertificate {
public function __construct($data, $name) { public function __construct($data, $name) {
$this->name = $name; $this->name = $name;
$gmt = new \DateTimeZone('GMT'); $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); $info = openssl_x509_parse($data);
if(!is_array($info)) { if(!is_array($info)) {
throw new \Exception('Certificate could not get parsed.'); throw new \Exception('Certificate could not get parsed.');

View File

@ -50,6 +50,14 @@ class CertificateTest extends \Test\TestCase {
$certificate->getIssueDate(); $certificate->getIssueDate();
} }
/**
* @expectedException \Exception
* @expectedExceptionMessage Certificate could not get parsed.
*/
function testCertificateStartingWithFileReference() {
new Certificate('file://'.__DIR__ . '/../../data/certificates/goodCertificate.crt', 'bar');
}
public function testGetName() { public function testGetName() {
$this->assertSame('GoodCertificate', $this->goodCertificate->getName()); $this->assertSame('GoodCertificate', $this->goodCertificate->getName());
$this->assertSame('BadCertificate', $this->invalidCertificate->getName()); $this->assertSame('BadCertificate', $this->invalidCertificate->getName());