From 8d9c2e90b77d417f9715c95de91c629e80ca6603 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 26 Jan 2013 11:23:43 +0100 Subject: no need to store the cert anymore - just new initialize and send it --- certs/app/models/client_certificate.rb | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'certs/app/models/client_certificate.rb') diff --git a/certs/app/models/client_certificate.rb b/certs/app/models/client_certificate.rb index b664ff0..b2b8c0d 100644 --- a/certs/app/models/client_certificate.rb +++ b/certs/app/models/client_certificate.rb @@ -9,41 +9,23 @@ require 'openssl' require 'certificate_authority' require 'date' -class ClientCertificate < CouchRest::Model::Base +class ClientCertificate - timestamps! - - property :key, String # the client private RSA key - property :cert, String # the client x509 certificate, signed by the CA - property :valid_until, Time # expiration time of the client certificate - - before_validation :generate, :on => :create - - validates :key, :presence => true - validates :cert, :presence => true - - design do - end - - class << self - def valid_attributes_hash - {:key => "ABCD", :cert => "A123"} - end - end + attr_accessor :key # the client private RSA key + attr_accessor :cert # the client x509 certificate, signed by the CA # # generate the private key and client certificate # - def generate + def initialize cert = CertificateAuthority::Certificate.new # set subject cert.subject.common_name = random_common_name # set expiration - self.valid_until = months_from_yesterday(APP_CONFIG[:client_cert_lifespan]) cert.not_before = yesterday - cert.not_after = self.valid_until + cert.not_after = months_from_yesterday(APP_CONFIG[:client_cert_lifespan]) # generate key cert.serial_number.number = cert_serial_number -- cgit v1.2.3