Class: R509::CertificateAuthority::HTTP::ValidityPeriodConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/r509/certificateauthority/http/validityperiodconverter.rb

Instance Method Summary collapse

Instance Method Details

#convert(validity_period) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/r509/certificateauthority/http/validityperiodconverter.rb', line 3

def convert(validity_period)
  if validity_period.nil?
    raise ArgumentError, "Must provide validity period"
  end
  if validity_period.to_i <= 0
    raise ArgumentError, "Validity period must be positive"
  end
  {
    :not_before => Time.now - 6 * 60 * 60,
    :not_after => Time.now + validity_period.to_i,
  }
end