diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-04-15 13:33:37 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-04-20 12:58:57 +0200 |
commit | 9f61cf60d49367726bc9b147993dab39eafa0c7b (patch) | |
tree | 5628bf1ca02d710ff8c0d916279cee7501bf3548 /lib | |
parent | 930ae11f8e52e70640060eca5b69afdebe713c6b (diff) | |
download | nextcloud-server-9f61cf60d49367726bc9b147993dab39eafa0c7b.tar.gz nextcloud-server-9f61cf60d49367726bc9b147993dab39eafa0c7b.zip |
Verify if returned object is an array
The error has to be thrown at this point as otherwise errors and notices are thrown since the time cannot be parsed in L60 and L61
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/security/certificate.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/private/security/certificate.php b/lib/private/security/certificate.php index 468427d0702..0d7fcc4148d 100644 --- a/lib/private/security/certificate.php +++ b/lib/private/security/certificate.php @@ -49,18 +49,18 @@ class Certificate implements ICertificate { */ public function __construct($data, $name) { $this->name = $name; - try { - $gmt = new \DateTimeZone('GMT'); - $info = openssl_x509_parse($data); - $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; - $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; - $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); - $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); - $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; - $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; - } catch (\Exception $e) { + $gmt = new \DateTimeZone('GMT'); + $info = openssl_x509_parse($data); + if(!is_array($info)) { throw new \Exception('Certificate could not get parsed.'); } + + $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; + $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; + $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); + $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); + $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; + $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; } /** |