Class: RubyInstaller::Build::CaCertFile
- Inherits:
-
Object
- Object
- RubyInstaller::Build::CaCertFile
- Defined in:
- lib/ruby_installer/build/ca_cert_file.rb
Constant Summary collapse
- MOZILLA_CA_CSV_URI =
"https://ccadb-public.secure.force.com/mozilla/IncludedCACertificateReportPEMCSV"
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #download_ssl_cacert_pem ⇒ Object
-
#initialize(content = nil) ⇒ CaCertFile
constructor
A new instance of CaCertFile.
- #remove_comments(filecontent) ⇒ Object
Constructor Details
#initialize(content = nil) ⇒ CaCertFile
Returns a new instance of CaCertFile.
6 7 8 9 10 |
# File 'lib/ruby_installer/build/ca_cert_file.rb', line 6 def initialize(content=nil) content ||= download_ssl_cacert_pem @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/ruby_installer/build/ca_cert_file.rb', line 4 def content @content end |
Instance Method Details
#==(other) ⇒ Object
61 62 63 64 |
# File 'lib/ruby_installer/build/ca_cert_file.rb', line 61 def ==(other) self.class == other.class && remove_comments(content) == remove_comments(other.content) end |
#download_ssl_cacert_pem ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby_installer/build/ca_cert_file.rb', line 14 def download_ssl_cacert_pem require 'open-uri' require 'csv' require 'openssl' require 'stringio' csv_data = OpenURI.open_uri(MOZILLA_CA_CSV_URI) fd = StringIO.new fd.write <<-EOT ## ## Bundle of CA Root Certificates ## ## Certificate data from Mozilla as of: #{Time.now.utc} ## ## This is a bundle of X.509 certificates of public Certificate Authorities (CA). ## These were automatically extracted from Mozilla's root certificates CSV file ## downloaded from: ## #{MOZILLA_CA_CSV_URI} ## ## Further information about the CA certificate list can be found: ## https://wiki.mozilla.org/CA:IncludedCAs ## ## This file is used as default CA certificate list for Ruby. ## Conversion done with rubyinstaller-build version #{RubyInstaller::Build::GEM_VERSION}. ## EOT CSV.parse(csv_data, headers: true).select do |row| row["Trust Bits"].split(";").include?("Websites") end.map do |row| pem = row["PEM Info"] OpenSSL::X509::Certificate.new(pem.gsub(/\A'/,"").gsub(/'\z/,"")) end.sort_by do |cert| [cert.subject.to_a.sort, -cert.serial.to_i] end.each do |cert| sj = "#{ OpenSSL::X509::Name.new(cert.subject.to_a.sort) } - #{cert.serial.to_i}" fd.write "\n#{ sj }\n#{ "=" * sj.length }\n#{ cert.to_pem }\n" end fd.string end |
#remove_comments(filecontent) ⇒ Object
57 58 59 |
# File 'lib/ruby_installer/build/ca_cert_file.rb', line 57 def remove_comments(filecontent) filecontent.gsub(/^##.*$/, "") end |