diff --git a/lib/win32/certstore/mixin/helper.rb b/lib/win32/certstore/mixin/helper.rb index 44ac440..2be0342 100644 --- a/lib/win32/certstore/mixin/helper.rb +++ b/lib/win32/certstore/mixin/helper.rb @@ -26,6 +26,10 @@ def cert_ps_cmd(thumbprint, store_location: "LocalMachine", store_name: "My") <<-EOH $cert = Get-ChildItem Cert:\\#{store_location}\\#{store_name} -Recurse | Where-Object { $_.Thumbprint -eq "#{thumbprint}" } + if ([string]::IsNullOrEmpty($cert)){ + return "Certificate Not Found" + } + $certdata = [System.Convert]::ToBase64String($cert.RawData, 'InsertLineBreaks') $content = $null if($null -ne $cert)