From da0b3757735fdf94f6bbf2497eb38d0843bd68e1 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Mon, 30 Aug 2021 12:29:16 -0700 Subject: [PATCH] Fixed rb445 and rb446 - the unlink calls for the client-side certs need to be wrapped around a file-existence check --- app/Models/Setting.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Models/Setting.php b/app/Models/Setting.php index e32ffa64b0..13d7b38bc1 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -380,16 +380,20 @@ class Setting extends Model * one place where we will do that, so I'll just explicitly call * this method at that spot instead. It'll be easier to debug and understand. */ - if($this->ldap_client_tls_cert) { + if ($this->ldap_client_tls_cert) { file_put_contents(self::get_client_side_cert_path(), $this->ldap_client_tls_cert); } else { - unlink(self::get_client_side_cert_path()); + if (file_exists(self::get_client_side_cert_path())) { + unlink(self::get_client_side_cert_path()); + } } - if($this->ldap_client_tls_key) { + if ($this->ldap_client_tls_key) { file_put_contents(self::get_client_side_key_path(), $this->ldap_client_tls_key); } else { - unlink(self::get_client_side_key_path()); + if (file_exists(self::get_client_side_key_path())) { + unlink(self::get_client_side_key_path()); + } } }