Class: Net::Openvpn::Generators::Keys::Client
- Defined in:
- lib/net/openvpn/generators/keys/client.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #certificate ⇒ Object
-
#filepaths ⇒ Object
Returns an array containing the paths to the generated keys.
-
#generate ⇒ Object
Generates the certificates for a VPN client.
-
#initialize(name, **props) ⇒ Client
constructor
A new instance of Client.
- #key ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name, **props) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/net/openvpn/generators/keys/client.rb', line 7 def initialize(name, **props) super(name, props) end |
Instance Method Details
#certificate ⇒ Object
38 39 40 |
# File 'lib/net/openvpn/generators/keys/client.rb', line 38 def certificate "#{@props[:key_dir]}/#{@name}.crt" end |
#filepaths ⇒ Object
Returns an array containing the paths to the generated keys
34 35 36 |
# File 'lib/net/openvpn/generators/keys/client.rb', line 34 def filepaths [ key, certificate ] end |
#generate ⇒ Object
Generates the certificates for a VPN client
Raises ‘Net::Openvpn::Errors::KeyGeneration` if there were problems
Returns true if the generation was successful
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/net/openvpn/generators/keys/client.rb', line 17 def generate @key_dir.exist? or raise Errors::KeyGeneration, "Key directory has not been generated yet" Authority.exist? or raise Errors::KeyGeneration, "Certificate Authority has not been created" revoke! if valid? FileUtils.cd(@props[:easy_rsa]) do system "#{cli_prop_vars} ./pkitool #{@name}" end exist? or raise Errors::KeyGeneration, "Keys do not exist" valid? or raise Errors::KeyGeneration, "keys are not valid" true end |
#key ⇒ Object
42 43 44 |
# File 'lib/net/openvpn/generators/keys/client.rb', line 42 def key "#{@props[:key_dir]}/#{@name}.key" end |