win32-certstore 0.6.11 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 809701f00c09da8b2bbcf78e30eb51d03e939d33ea7a19b17d45ce51c078fdd4
4
- data.tar.gz: dbb26074a01b06639bbc1bae73b45f1937c54035ad57d56bbecc64a3fb377bb6
3
+ metadata.gz: b4a48182fe9aada5c09a9e0205bc5a3a53fd1b50da8fa3a5abfd649adce8fac0
4
+ data.tar.gz: 2803b6ddc28e7575f2c9f3709c42e8509c42cef7c5b6ca9e85884dd51be14dd9
5
5
  SHA512:
6
- metadata.gz: 9ba534e93f989c33a735ea57f525b5357f25cbd0f7c9d2ad0bfe770a0d59f49973dde9669cfb878de35853a81d4af7257d39348d3406879273cdf338b108acd7
7
- data.tar.gz: c16cd054c55671396b73d0d41450d89e54dd7157a7b21ea7df0dedadea67c5f376ef45b9e6a70bfaf4eb9ceadfaa520399caa0ee49fb722afec3fcef6e39d405
6
+ metadata.gz: b4569f5dcf1f73d12dd9d82515b2ee0f2d270488118c0c0f0b7f4f079ba7c65cc8dcf7e1321221c68f4465c4858195c752a78c19de3345e795b618ecab616e4f
7
+ data.tar.gz: c0d0e669883c027786d41eea3eea9b85c66bc7391675f63a60c8f5229115b73a2e617268a415d741d164a3621688c98902871d1eb764e4c07c2b5ef88a4f3aa8
@@ -146,10 +146,11 @@ module Win32
146
146
  def cert_validate(certificate_thumbprint)
147
147
  validate_thumbprint(certificate_thumbprint)
148
148
  thumbprint = update_thumbprint(certificate_thumbprint)
149
-
150
149
  cert_pem = get_cert_pem(thumbprint)
150
+ return cert_pem if cert_pem == "Certificate Not Found"
151
151
  cert_pem = format_pem(cert_pem)
152
- verify_certificate(cert_pem)
152
+ result = verify_certificate(cert_pem)
153
+ result == false ? "Certificate Has Expired" : result
153
154
  end
154
155
 
155
156
  # Search certificate from open certificate store and return list
@@ -184,13 +185,16 @@ module Win32
184
185
  end
185
186
  powershell_cmd = <<~EOH
186
187
  $result = Get-ChildItem -Path Cert:\\#{converted_store}\\#{store_name} | Where-Object { $_.Subject -match "#{search_token.strip}" } | Select-Object Thumbprint
188
+ if ([string]::IsNullOrEmpty($result)){
189
+ return "Certificate Not Found"
190
+ }
187
191
  return $result[0].Thumbprint
188
192
  EOH
189
193
 
190
194
  powershell_exec!(powershell_cmd, :powershell, timeout: timeout).result
191
195
 
192
196
  rescue ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed
193
- return "Certificate not found"
197
+ raise ArgumentError, "PowerShell threw an error retreiving the certificate. You asked for a cert with this Search Token : #{search_token}, located in this store : #{store_name}, at this location : #{store_location}"
194
198
  end
195
199
 
196
200
  # To close and destroy pointer of open certificate store handler
@@ -1,6 +1,6 @@
1
1
  module Win32
2
2
  class Certstore
3
- VERSION = "0.6.11".freeze
3
+ VERSION = "0.6.12".freeze
4
4
  MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
@@ -84,7 +84,7 @@ module Win32
84
84
  def get!(certificate_thumbprint)
85
85
  cert_pem = cert_get(certificate_thumbprint)
86
86
 
87
- raise ArgumentError, "Unable to retrieve the certificate" if cert_pem.empty?
87
+ raise ArgumentError, "Unable to retrieve the certificate" if cert_pem.empty? || cert_pem == "Certificate Not Found"
88
88
 
89
89
  cert_pem
90
90
  end
@@ -118,13 +118,7 @@ module Win32
118
118
  # @param request[thumbprint<string>] of certificate
119
119
  # @return [true, false] only true or false
120
120
  def valid?(certificate_thumbprint)
121
- cert_validate(certificate_thumbprint).yield_self do |x|
122
- if x.is_a?(TrueClass) || x.is_a?(FalseClass)
123
- x
124
- else
125
- false
126
- end
127
- end
121
+ cert_validate(certificate_thumbprint)
128
122
  end
129
123
 
130
124
  # To close and destroy pointer of open certificate store handler
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-certstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
4
+ version: 0.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-09 00:00:00.000000000 Z
11
+ date: 2022-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler