lib/evil-proxy/quickcert.rb
##
# Creates a new certificate from +cert_config+ that is signed
# by the CA.
Creates a new certificate from +cert_config+ that is signed
by the CA.
Creates a new certificate from + cert_config + that is signed by the CA .
def create_cert(cert_config)
    dest = cert_config[:hostname] || cert_config[:user]
    key_file = "#{CERT_DIR}/#{dest}/#{dest}_keypair.pem"
    cert_file = "#{CERT_DIR}/#{dest}/cert_#{dest}.pem"
    if File.exists?(cert_file) && File.exists?(key_file)
      key = OpenSSL::PKey::RSA.new(File.read(key_file))
      cert = OpenSSL::X509::Certificate.new(File.read(cert_file))
    else
      cert_keypair, key = create_key(cert_config)
      cert_csr = create_csr(cert_config, cert_keypair)
      cert_file, cert = sign_cert(cert_config, cert_keypair, cert_csr)
    end
    return cert_file, cert, key
  end
def create_cert ( cert_config ) dest = cert_config [ :hostname ] || cert_config [ :user ] key_file = "#{CERT_DIR}/#{dest}/#{dest}_keypair.pem" cert_file = "#{CERT_DIR}/#{dest}/cert_#{dest}.pem" if File . exists? ( cert_file ) && File . exists? ( key_file ) key = OpenSSL :: PKey :: RSA . new ( File . read ( key_file ) ) cert = OpenSSL :: X509 :: Certificate . new ( File . read ( cert_file ) ) else cert_keypair , key = create_key ( cert_config ) cert_csr = create_csr ( cert_config , cert_keypair ) cert_file , cert = sign_cert ( cert_config , cert_keypair , cert_csr ) end return cert_file , cert , key end
Creates a new certificate from +cert_config+ that is signed
by the CA.
Creates a new certificate from + cert_config + that is signed by the CA .
cert_config