From 9c91af5ee25d8bda74a23d148fc7b3251146e3e5 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 24 May 2018 00:24:28 +1200 Subject: [PATCH] Deletion managed by function, used for renewal as well as revoke. --- src/services/OrderService.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/services/OrderService.php b/src/services/OrderService.php index 39c6371..a31896d 100644 --- a/src/services/OrderService.php +++ b/src/services/OrderService.php @@ -209,10 +209,7 @@ public function init() if ($this->_renew) { - foreach ($pathMap as $propertyName => $fileName) - { - @unlink($basePath.DIRECTORY_SEPARATOR.$fileName); - } + $this->removeLocalData(); } is_file($this->_orderInfoPath) ? $this->getOrder() : $this->createOrder(); @@ -462,6 +459,8 @@ public function revokeCertificate($reason = 0) throw new OrderException("Revoke certificate failed, the domain list is: ".implode(', ', $this->_domainList).", the code is: {$code}, the header is: {$header}, the body is: ".print_r($body, TRUE)); } + $this->removeLocalData(); + return TRUE; } @@ -641,4 +640,24 @@ private function populate($orderInfo) $this->{$key} = $value; } } -} + + /** + * Remove local copy of certificate data + * @return boolean + */ + private function removeLocalData() + { + $filesToUnlink = [ + $this->_privateKeyPath, + $this->_publicKeyPath, + $this->_csrPath, + $this->_certificatePath, + $this->_certificateFullChainedPath, + $this->_orderInfoPath, + ]; + foreach ($filesToUnlink as $file) + { + @unlink($file); + } + } +} \ No newline at end of file