lib/vpnmaker/config_generator.rb in vpnmaker-1.0.0 vs lib/vpnmaker/config_generator.rb in vpnmaker-1.0.1

- old
+ new

@@ -12,24 +12,31 @@ :dh => File.read(@dirname + "/dh.pem"), :ca => File.read(@dirname + "/ca.crt"), :ta => File.read(@dirname + "/ta.key") } end + def client_conf(client) + fname = client[:user] + '-' + ((client[:revoked].max || - 1) + 1).to_s + separator = '-----BEGIN CERTIFICATE-----' + cert = File.read(@dirname + "/#{fname}.crt").split(separator).last.insert(0, separator) + { :gen_host => Socket.gethostname, :server => @mgr.config[:server], :client => @mgr.config[:client] - }.merge(client).merge(:key => File.read(@dirname + "/#{client[:user]}-#{(client[:revoked].max || - 1) + 1}.key" ), - :cert => File.read(@dirname + "/#{client[:user]}-#{(client[:revoked].max || - 1) + 1}.crt")).merge(@runtime_cfg) + }.merge(client).merge(:key => File.read(@dirname + "/#{fname}.key" ), + :cert => cert).merge(@runtime_cfg) end def server_conf + separator = '-----BEGIN CERTIFICATE-----' + cert = File.read(@dirname + "/server.crt").split(separator).last.insert(0, separator) { :gen_host => Socket.gethostname }.merge(@mgr.config[:server]).merge(@runtime_cfg).merge(:key => File.read(@dirname + "/server.key"), - :cert => File.read(@dirname + "/server.crt"), + :cert => cert, :crl => File.read(@dirname + "/crl.pem")) end def server haml_vars = server_conf.dup @@ -45,10 +52,9 @@ def client(client) haml_vars = client_conf(client).dup template = File.read(@mgr.tracker.path + \ "/" + @mgr.config[:site][:template_dir] + \ "/" + 'client.haml') - # template = File.read(__FILE__.path('client.haml')) Haml::Engine.new(template).render(Object.new, haml_vars) end end end