diff --git a/lib/win32/certstore/store_base.rb b/lib/win32/certstore/store_base.rb index 1ae2d52..bf0b52c 100644 --- a/lib/win32/certstore/store_base.rb +++ b/lib/win32/certstore/store_base.rb @@ -190,7 +190,7 @@ def cert_lookup_by_token(search_token, store_name: @store_name, store_location: powershell_exec!(powershell_cmd, :powershell, timeout: timeout).result rescue ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed - raise ArgumentError, "Certificate not found while looking for certificate : #{search_token} in store : #{store_name} at this location : #{store_location}" + return "Certificate not found" end # To close and destroy pointer of open certificate store handler diff --git a/spec/win32/unit/certstore_spec.rb b/spec/win32/unit/certstore_spec.rb index 988419d..51acfcc 100644 --- a/spec/win32/unit/certstore_spec.rb +++ b/spec/win32/unit/certstore_spec.rb @@ -267,6 +267,16 @@ end end + describe "#cert_lookup_by_token" do + context "when searching for a certificate that does not exist" do + let(:store_name) { "root" } + it "returns a message of Certificate not found" do + store = certstore.open(store_name, store_location: store_location) + expect(store.cert_lookup_by_token("nunya")).to eql("Certificate not found") + end + end + end + describe "#cert_validate" do context "When passing empty certificate store name to the CurrentUser store" do let(:store_name) { "" }