diff options
author | elijah <elijah@riseup.net> | 2016-07-01 14:49:27 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2016-07-01 14:49:27 -0700 |
commit | 174dbf380fe1b0962a9e173caa6dd0a0f76a14e1 (patch) | |
tree | d2f1414652d2c0fbd1003347c2abf2be1ffff473 /lib/leap_cli/util/x509.rb | |
parent | 2d277c7d2aa3ddfbe3c2c65f68d7290930934b70 (diff) | |
parent | f9284ff22da6eec685782dbc9aa4a4ded0efec29 (diff) |
Merge branch 'feature/newcli' into develop
Diffstat (limited to 'lib/leap_cli/util/x509.rb')
-rw-r--r-- | lib/leap_cli/util/x509.rb | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/lib/leap_cli/util/x509.rb b/lib/leap_cli/util/x509.rb deleted file mode 100644 index 787fdfa..0000000 --- a/lib/leap_cli/util/x509.rb +++ /dev/null @@ -1,33 +0,0 @@ -autoload :OpenSSL, 'openssl' -autoload :CertificateAuthority, 'certificate_authority' - -require 'digest' -require 'digest/md5' -require 'digest/sha1' - -module LeapCli; module X509 - extend self - - # - # returns a fingerprint of a x509 certificate - # - def fingerprint(digest, cert_file) - if cert_file.is_a? String - cert = OpenSSL::X509::Certificate.new(Util.read_file!(cert_file)) - elsif cert_file.is_a? OpenSSL::X509::Certificate - cert = cert_file - elsif cert_file.is_a? CertificateAuthority::Certificate - cert = cert_file.openssl_body - end - digester = case digest - when "MD5" then Digest::MD5.new - when "SHA1" then Digest::SHA1.new - when "SHA256" then Digest::SHA256.new - when "SHA384" then Digest::SHA384.new - when "SHA512" then Digest::SHA512.new - end - digester.hexdigest(cert.to_der) - end - - -end; end |