Sha256: f863dbc5cc7bdb699d7aaeb7fea5938cec6f2978253693a74a819dafcc58d865

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'openssl'

module ApplePushCerts
  module Customer
    class CSR < OpenSSL::X509::Request
   
      def initialize(key=nil)
        key ||= Key.new
        csr   = OpenSSL::X509::Request.new
        
        options = {
          country:      '',
          state:        '',
          city:         '',
          organization: '',
          department:   '',
          common_name:  '',
          email:        ''
        }

        csr.version = 0 
        csr.subject = OpenSSL::X509::Name.new([
          ['C',             options[:country],      OpenSSL::ASN1::PRINTABLESTRING],
          ['ST',            options[:state],        OpenSSL::ASN1::PRINTABLESTRING],
          ['L',             options[:city],         OpenSSL::ASN1::PRINTABLESTRING],
          ['O',             options[:organization], OpenSSL::ASN1::UTF8STRING],
          ['OU',            options[:department],   OpenSSL::ASN1::UTF8STRING],
          ['CN',            options[:common_name],  OpenSSL::ASN1::UTF8STRING],
          ['emailAddress',  options[:email],        OpenSSL::ASN1::UTF8STRING]
        ])

        csr.public_key = key.public_key
        csr.sign key, OpenSSL::Digest::SHA1.new
        
        super csr
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apple_push_certs-0.0.1 lib/apple_push_certs/customer/csr.rb