Class: PEM::SigningRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/pem/signing_request.rb

Class Method Summary collapse

Class Method Details

.generateObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pem/signing_request.rb', line 9

def self.generate
  Helper.log.info "Creating a signing certificate for you.".green
  @key = OpenSSL::PKey::RSA.new 2048
 
  # Generate CSR
  csr = OpenSSL::X509::Request.new
  csr.version = 0 
  csr.subject = OpenSSL::X509::Name.new([
    ['CN', "PEM", OpenSSL::ASN1::UTF8STRING]
  ])
  csr.public_key = @key.public_key
  csr.sign @key, OpenSSL::Digest::SHA1.new
   
  path = File.join(TMP_FOLDER, 'PEMCertificateSigningRequest.certSigningRequest')
  File.write(path, csr.to_pem)
  File.write(File.join(TMP_FOLDER, 'private_key.key'), @key)

  Helper.log.info "Successfully generated .certSigningRequest at path '#{path}'"
  return path
end

.get_pathObject


5
6
7
# File 'lib/pem/signing_request.rb', line 5

def self.get_path
  self.generate
end