From 861a7bbde66318889f6030e31e8a38384f3b95eb Mon Sep 17 00:00:00 2001 From: Tristan Date: Mon, 18 Feb 2019 11:52:35 +0100 Subject: [PATCH] Export without the need for a private key EXO-3319 --- CHANGELOG.md | 7 ++++++- src/Formats/Plain.php | 16 +++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4cf59c..a4530a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,12 @@ All notable changes to `SSL converter` will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. ## Unreleased -[Compare v0.0.1 - Unreleased](https://github.com/exonet/ssl-converter/compare/v0.0.1...develop) +[Compare v0.0.2 - Unreleased](https://github.com/exonet/ssl-converter/compare/v0.0.1...develop) + +## [v0.0.2](https://github.com/exonet/ssl-converter/releases/tag/v0.0.2) - 2019-02-18 +[Compare v0.0.1 - v0.0.2](https://github.com/exonet/ssl-converter/compare/v0.0.1...v0.0.2) +### Changed +- It is now possible to export to "Plain" without a private key. ## [v0.0.1](https://github.com/exonet/ssl-converter/releases/tag/v0.0.1) - 2019-01-30 ### Added diff --git a/src/Formats/Plain.php b/src/Formats/Plain.php index 880bf49..31e81a2 100644 --- a/src/Formats/Plain.php +++ b/src/Formats/Plain.php @@ -24,11 +24,17 @@ class Plain extends AbstractFormat */ public function export() : array { - return [ - $this->name.'.key' => $this->plainCertificate->getKey(), - $this->name.'.crt' => $this->plainCertificate->getCrt(), - $this->name.'.ca-bundle' => $this->plainCertificate->getCaBundle(), - ]; + $files = []; + + // Add the key only if it is not empty. + if (!empty($this->plainCertificate->getKey())) { + $files[$this->name.'.key'] = $this->plainCertificate->getKey(); + } + + $files[$this->name.'.crt'] = $this->plainCertificate->getCrt(); + $files[$this->name.'.ca-bundle'] = $this->plainCertificate->getCaBundle(); + + return $files; } /**