class Net::Openvpn::Generators::Keys::Client

Public Class Methods

new(name, **props) click to toggle source
# File lib/net/openvpn/generators/keys/client.rb, line 7
def initialize(name, **props)
  super(name, props)
end

Public Instance Methods

certificate() click to toggle source
# File lib/net/openvpn/generators/keys/client.rb, line 38
def certificate
  "#{@props[:key_dir]}/#{@name}.crt"
end
filepaths() click to toggle source

Returns an array containing the paths to the generated keys

# File lib/net/openvpn/generators/keys/client.rb, line 34
def filepaths
  [ key, certificate ]
end
generate() click to toggle source

Generates the certificates for a VPN client

Raises ‘Net::Openvpn::Errors::KeyGeneration` if there were problems

Returns true if the generation was successful

# 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() click to toggle source
# File lib/net/openvpn/generators/keys/client.rb, line 42
def key
  "#{@props[:key_dir]}/#{@name}.key"
end