Skip to content

Commit

Permalink
add get! method, remove string return from verify_certificate
Browse files Browse the repository at this point in the history
Signed-off-by: rishichawda <[email protected]>
  • Loading branch information
rishichawda committed Sep 7, 2021
1 parent 7d81f70 commit ed5ec4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/win32/certstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def get(certificate_thumbprint, store_name: @store_name, store_location: @store_
cert_get(certificate_thumbprint, store_name: store_name, store_location: store_location)
end

# Return `OpenSSL::X509` certificate object if present otherwise raise a "Certificate not found!" error
# @param request [thumbprint<string>] of certificate
# @return [Object] of certificates in OpenSSL::X509 format
def get!(certificate_thumbprint, store_name: @store_name, store_location: @store_location)
cert_pem = cert_get(certificate_thumbprint, store_name: store_name, store_location: store_location)

raise "Certificate not found!" if cert_pem.empty?

cert_pem
end

# Returns all the certificates in a store
# @param [nil]
# @return [Array] array of certificates list
Expand Down
2 changes: 0 additions & 2 deletions lib/win32/certstore/store_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ def update_thumbprint(certificate_thumbprint)

# Verify OpenSSL::X509::Certificate object
def verify_certificate(cert_pem)
return "Certificate not found" if cert_pem.empty?

valid_duration?(build_openssl_obj(cert_pem))
end

Expand Down

0 comments on commit ed5ec4b

Please sign in to comment.