def create_ssl_certificate(cert_params)
      file_path = cert_params[:output_file].sub(/\.(\w+)$/, "")
      path = prompt_for_file_path
      file_path = File.join(path, file_path) unless path.empty?
      cert_params[:domain] = prompt_for_domain

      rsa_key = generate_keypair cert_params[:key_length]
      cert = generate_certificate(rsa_key, cert_params)
      write_certificate_to_file cert, file_path, rsa_key, cert_params
      puts "*" * 70
      puts "Generated Certificates:"
      puts "- #{file_path}.pfx - PKCS12 format keypair. Contains both the public and private keys, usually used on the server."
      puts "- #{file_path}.b64 - Base64 encoded PKCS12 keypair. Contains both the public and private keys, for upload to the Azure REST API."
      puts "- #{file_path}.pem - Base64 encoded public certificate only. Required by the client to connect to the server."
      puts "Certificate Thumbprint: #{@thumbprint.to_s.upcase}"
      puts "*" * 70

      Chef::Config[:knife][:ca_trust_file] = file_path + ".pem" if Chef::Config[:knife][:ca_trust_file].nil?
      cert_data = File.read (file_path + ".b64")
      add_certificate cert_data, @winrm_cert_passphrase, "pfx", cert_params[:azure_dns_name]
      @thumbprint
    end
def create_ssl_certificate(cert_params)
      file_path = cert_params[:output_file].sub(/\.(\w+)$/, "")
      path = prompt_for_file_path
      file_path = File.join(path, file_path) unless path.empty?
      cert_params[:domain] = prompt_for_domain

      rsa_key = generate_keypair cert_params[:key_length]
      cert = generate_certificate(rsa_key, cert_params)
      write_certificate_to_file cert, file_path, rsa_key, cert_params
      puts "*" * 70
      puts "Generated Certificates:"
      puts "- #{file_path}.pfx - PKCS12 format keypair. Contains both the public and private keys, usually used on the server."
      puts "- #{file_path}.b64 - Base64 encoded PKCS12 keypair. Contains both the public and private keys, for upload to the Azure REST API."
      puts "- #{file_path}.pem - Base64 encoded public certificate only. Required by the client to connect to the server."
      puts "Certificate Thumbprint: #{@thumbprint.to_s.upcase}"
      puts "*" * 70

      Chef::Config[:knife][:ca_trust_file] = file_path + ".pem" if Chef::Config[:knife][:ca_trust_file].nil?
      cert_data = File.read (file_path + ".b64")
      add_certificate cert_data, @winrm_cert_passphrase, "pfx", cert_params[:azure_dns_name]
      @thumbprint
    end
SSL certificate generation for knife-azure ssl bootstrap