Skip to content

Commit

Permalink
MSYS-547 Added feature to verify certificate from certificate store
Browse files Browse the repository at this point in the history
Signed-off-by: piyushawasthi <[email protected]>
  • Loading branch information
piyushawasthi committed Mar 28, 2018
1 parent e4db9b5 commit 9fbf8fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/win32/certstore/mixin/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'date'

module Win32
class Certstore
module Mixin
Expand All @@ -41,8 +43,8 @@ def cert_ps_cmd(thumbprint)
def valid_duration(cert_obj)
cert_obj.not_before < Time.now.utc && cert_obj.not_after > Time.now.utc
end

end
end
end
end

6 changes: 6 additions & 0 deletions lib/win32/certstore/store_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ def update_thumbprint(certificate_thumbprint)
certificate_thumbprint.gsub(/[^A-Za-z0-9]/, '')
end

# 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

# Convert OpenSSL::X509::Certificate object in .der formate
def der_cert(cert_obj)
FFI::MemoryPointer.from_string(cert_obj.to_der)
Expand Down

0 comments on commit 9fbf8fe

Please sign in to comment.