Class: EaSSL::CertificateName

Inherits:
Object
  • Object
show all
Defined in:
lib/eassl/certificate_name.rb

Overview

Author

Paul Nicholson ([email protected])

Co-Author

Adam Williams ([email protected])

Copyright

Copyright © 2006 WebPower Design

License

Distributes under the same terms as Ruby

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CertificateName

Returns a new instance of CertificateName.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/eassl/certificate_name.rb', line 9

def initialize(options)
  @options = {
    :country      => "US",
    :state        => "North Carolina",
    :city         => "Fuquay Varina",
    :organization => "WebPower Design",
    :department   => "Web Security",
    :common_name  =>  nil,                     # required
    :email        => "[email protected]",
  }.update(options)
end

Instance Method Details

#nameObject



33
34
35
# File 'lib/eassl/certificate_name.rb', line 33

def name
  ssl
end

#optionsObject



37
38
39
# File 'lib/eassl/certificate_name.rb', line 37

def options
  @options
end

#sslObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/eassl/certificate_name.rb', line 21

def ssl
  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]
  ])
end