build_self_signed_cert(email_addr, opt = {})
public
Build a self-signed certificate for the given email address.
# File lib/rubygems/security.rb, line 704
def self.build_self_signed_cert(email_addr, opt = {})
Gem.ensure_ssl_available
opt = OPT.merge(opt)
path = { :key => nil, :cert => nil }
name = email_to_name email_addr, opt[:munge_re]
key = opt[:key_algo].new opt[:key_size]
verify_trust_dir opt[:trust_dir], opt[:perms][:trust_dir]
if opt[:save_key] then
path[:key] = opt[:save_key_path] || (opt[:output_fmt] % 'private_key')
open path[:key], 'wb' do |io|
io.chmod opt[:perms][:signing_key]
io.write key.to_pem
end
end
cert = build_cert name, key, opt
if opt[:save_cert] then
path[:cert] = opt[:save_cert_path] || (opt[:output_fmt] % 'public_cert')
open path[:cert], 'wb' do |file|
file.chmod opt[:perms][:signing_cert]
file.write cert.to_pem
end
end
{ :key => key, :cert => cert,
:key_path => path[:key], :cert_path => path[:cert] }
end