Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring to correct for not finding certs correctly in some cases. #95

Merged
merged 2 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/win32/certstore/mixin/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def validate_certificate_obj(cert_obj)

# Validate thumbprint
def validate_thumbprint(cert_thumbprint)
if cert_thumbprint.nil? || cert_thumbprint.empty? || cert_thumbprint.strip.empty?
if cert_thumbprint.nil? || cert_thumbprint.empty? || cert_thumbprint.strip.empty? || cert_thumbprint.length < 40
raise ArgumentError, "Invalid certificate thumbprint."
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/win32/certstore/mixin/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down