This will become a rails application as client for LXD.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

25 lines
631 B

class Lxd::Certificate
include ActiveModel::Model
def save(host, certificate)
all = Array.new;
uri = URI.parse(host.uri + '/1.0/certificates')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(certificate.cert)
http.key = OpenSSL::PKey::RSA.new(certificate.key)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
request.body = {
:type => 'client',
:name => 'foo',
:password => '[where to get this from....]'
}.to_json
response = http.request(request)
response.code
end
end
# vim: set ts=2 sw=2: