summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-09 16:11:20 +0200
committerAzul <azul@leap.se>2014-05-19 14:24:46 +0200
commite94b9471c0bc30cd6a1a5bf5b6b22b746d242e31 (patch)
tree5821821d23da6ed2230eb777240c972cd988c238 /app/models
parentb9174fdc9d9bd403d9a16650bafc4715e3dbf2d4 (diff)
calculate cert fingerprints to store for leap_mx
stelfox.net/blog/2014/04/calculating-rsa-key-fingerprints-in-ruby/
Diffstat (limited to 'app/models')
-rw-r--r--app/models/client_certificate.rb8
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])