diff options
author | Azul <azul@leap.se> | 2014-05-09 16:11:20 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-05-19 14:24:46 +0200 |
commit | e94b9471c0bc30cd6a1a5bf5b6b22b746d242e31 (patch) | |
tree | 5821821d23da6ed2230eb777240c972cd988c238 | |
parent | b9174fdc9d9bd403d9a16650bafc4715e3dbf2d4 (diff) |
calculate cert fingerprints to store for leap_mx
stelfox.net/blog/2014/04/calculating-rsa-key-fingerprints-in-ruby/
-rw-r--r-- | app/models/client_certificate.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/client_certificate.rb b/app/models/client_certificate.rb index 76b07a2..63de9e1 100644 --- a/app/models/client_certificate.rb +++ b/app/models/client_certificate.rb @@ -43,8 +43,16 @@ class ClientCertificate self.key.to_pem + self.cert.to_pem end + def fingerprint + OpenSSL::Digest::SHA1.hexdigest(openssl_cert.to_der).scan(/../).join(':') + end + private + def openssl_cert + cert.openssl_body + end + def self.root_ca @root_ca ||= begin crt = File.read(APP_CONFIG[:client_ca_cert]) |