Class: Net::Openvpn::Generators::Keys::Client
- Defined in:
- lib/net/openvpn/generators/keys/client.rb
Instance Method Summary collapse
-
#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.
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
#filepaths ⇒ Object
Returns an array containing the paths to the generated keys
34 35 36 37 38 39 |
# File 'lib/net/openvpn/generators/keys/client.rb', line 34 def filepaths [ "#{@props[:key_dir]}/#{@name}.key", "#{@props[:key_dir]}/#{@name}.crt" ] 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 exist? and 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 |