class EaSSL::CertificateName

Author

Paul Nicholson (paul@webpowerdesign.net)

Co-Author

Adam Williams (adam@thewilliams.ws)

Copyright

Copyright © 2006 WebPower Design

License

Distributes under the same terms as Ruby

Public Class Methods

new(options) click to toggle source
# File lib/eassl/certificate_name.rb, line 9
def initialize(options)
  @options = options
end

Public Instance Methods

name() click to toggle source
# File lib/eassl/certificate_name.rb, line 32
def name
  ssl
end
options() click to toggle source
# File lib/eassl/certificate_name.rb, line 36
def options
  @options
end
ssl() click to toggle source
# File lib/eassl/certificate_name.rb, line 13
def ssl
  name_mapping = [
    ['C', :country, OpenSSL::ASN1::PRINTABLESTRING],
    ['ST', :state, OpenSSL::ASN1::PRINTABLESTRING],
    ['L', :city, OpenSSL::ASN1::PRINTABLESTRING],
    ['O', :organization, OpenSSL::ASN1::UTF8STRING],
    ['OU', :department, OpenSSL::ASN1::UTF8STRING],
    ['CN', :common_name, OpenSSL::ASN1::UTF8STRING],
    ['emailAddress', :email, OpenSSL::ASN1::IA5STRING]
  ]

  name = []
  name_mapping.each do |k|
    name << [k[0], @options[k[1]], k[2]] if @options[k[1]]
  end

  OpenSSL::X509::Name.new(name)
end