From 30a7d6f25738fdd3c6cd5d5cb6efa03f20126d96 Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Thu, 26 Mar 2020 07:33:28 +0100 Subject: [PATCH] Adds exceptions in case source Cert file is missing as argument or invalid --- lib/web/ConvertTo-IcingaX509Certificate.psm1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/web/ConvertTo-IcingaX509Certificate.psm1 b/lib/web/ConvertTo-IcingaX509Certificate.psm1 index 3ca8038..d1c4e44 100644 --- a/lib/web/ConvertTo-IcingaX509Certificate.psm1 +++ b/lib/web/ConvertTo-IcingaX509Certificate.psm1 @@ -6,6 +6,14 @@ function ConvertTo-IcingaX509Certificate() [switch]$Force = $FALSE ); + if ([string]::IsNullOrEmpty($CertFile)) { + throw 'Please specify a valid path to an existing certificate (.cer, .pem, .cert)'; + } + + if ((Test-Path $CertFile) -eq $FALSE) { + throw 'The provided path to your certificate was not valid'; + } + # Use an empty password for converted certificates $Password = $null; # Use a target file to specify if we use temp files or not