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
15
16
17
# 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
  {
    # Begin the validity period 6 hours into the past, to account for
    # possibly-slow clocks.
    :not_before => Time.now - (6 * 60 * 60),
    # Add validity_period number of seconds to the current time.
    :not_after => Time.now + validity_period.to_i,
  }
end