Module: EasyRSA
- Extended by:
- EasyRSA
- Included in:
- EasyRSA
- Defined in:
- lib/easyrsa.rb,
lib/easyrsa/ca.rb,
lib/easyrsa/dh.rb,
lib/easyrsa/cli.rb,
lib/easyrsa/config.rb,
lib/easyrsa/revoke.rb,
lib/easyrsa/version.rb,
lib/easyrsa/certificate.rb
Defined Under Namespace
Modules: CLI, Config Classes: CA, Certificate, DH, Revoke
Constant Summary collapse
- VERSION =
'1.0.0'
Instance Method Summary collapse
-
#configure ⇒ Object
(also: #config)
The Configure Block.
-
#gen_issuer ⇒ Object
Helper for issuer details.
-
#gen_serial(id) ⇒ Object
Helper for generating serials.
-
#years_from_now(i = 10) ⇒ Object
Helper for years from now.
Instance Method Details
#configure ⇒ Object Also known as: config
The Configure Block
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/easyrsa.rb', line 17 def configure block_given? ? yield(Config) : Config %w(email server country city company orgunit).each do |key| if EasyRSA::Config.instance_variable_get("@#{key}").nil? raise EasyRSA::Config::RequiredOptionMissing, "Configuration parameter missing: '#{key}'. " + "Please add it to the EasyRSA.configure block" end end end |
#gen_issuer ⇒ Object
Helper for issuer details
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/easyrsa.rb', line 35 def gen_issuer name = "/C=#{EasyRSA::Config.country}" name += "/ST=#{EasyRSA::Config.state}" unless !EasyRSA::Config.state || EasyRSA::Config.state.empty? name += "/L=#{EasyRSA::Config.city}" name += "/O=#{EasyRSA::Config.company}" name += "/OU=#{EasyRSA::Config.orgunit}" name += "/CN=#{EasyRSA::Config.server}" name += "/name=#{EasyRSA::Config.name}" unless !EasyRSA::Config.name || EasyRSA::Config.name.empty? name += "/emailAddress=#{EasyRSA::Config.email}" OpenSSL::X509::Name.parse(name) end |
#gen_serial(id) ⇒ Object
Helper for generating serials
49 50 51 52 |
# File 'lib/easyrsa.rb', line 49 def gen_serial(id) # Must always be unique, so we do date and id's chars "#{Time.now.strftime('%Y%m%d%H%M%S')}#{id.unpack('c*').join.to_i}".to_i end |
#years_from_now(i = 10) ⇒ Object
Helper for years from now
30 31 32 |
# File 'lib/easyrsa.rb', line 30 def years_from_now(i = 10) Time.now + i * 365 * 24 * 60 * 60 end |