Module: EaSSL
- Defined in:
- lib/eassl.rb,
lib/eassl/key.rb,
lib/eassl/serial.rb,
lib/eassl/certificate.rb,
lib/eassl/signing_request.rb,
lib/eassl/certificate_name.rb,
lib/eassl/authority_certificate.rb,
lib/eassl/certificate_authority.rb
Overview
-
EaSSL::SigningRequest: the class for creating SSL signing requests
Defined Under Namespace
Classes: AuthorityCertificate, Certificate, CertificateAuthority, CertificateName, Key, Serial, SigningRequest
Constant Summary collapse
- VERSION =
'2.0.0'
Class Method Summary collapse
Class Method Details
.config_webrick(webrick_config, options = {}) ⇒ Object
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 56 57 58 59 60 61 62 |
# File 'lib/eassl.rb', line 31 def self.config_webrick(webrick_config, = {}) hostname = `hostname`.strip eassl_host_dir = "#{File.('~')}/.eassl/#{hostname}" ca_cert_file = "#{eassl_host_dir}/ca.crt" ca_key_file = "#{eassl_host_dir}/ca.key" server_key_file = "#{eassl_host_dir}/server.key" server_cert_file = "#{eassl_host_dir}/server.crt" FileUtils.rm_rf(eassl_host_dir) if [:force_regeneration] if File.exist?(server_cert_file) key = Key.load(server_key_file, 'countinghouse1234') cert = Certificate.load(server_cert_file) else ca, sr, cert = self.generate_self_signed({:name => {:common_name => hostname}, :bits => 1024}.update()) key = sr.key FileUtils.makedirs(eassl_host_dir) File.open(%(#{ca_cert_file}.pem), "w", 0777) {|f| f << ca.certificate.to_pem } File.open(%(#{ca_cert_file}.der), "w", 0777) {|f| f << ca.certificate.to_der } File.open(ca_key_file, "w", 0777) {|f| f << ca.key.to_pem } File.open(server_key_file, "w", 0777) {|f| f << key.to_pem } File.open(server_cert_file, "w", 0777) {|f| f << cert.to_pem } end webrick_config.update({ :SSLEnable => true, :SSLPrivateKey => key.ssl, :SSLCertificate => cert.ssl, :SSLExtraChainCert => [Certificate.load(%(#{ca_cert_file}.pem)).ssl], :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, :SSLStartImmediately => true, }) end |
.generate_self_signed(options) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/eassl.rb', line 24 def self.generate_self_signed() ca = CertificateAuthority.new({:bits => 1024}.update([:ca_options]||{})) sr = SigningRequest.new() cert = ca.create_certificate(sr) [ca, sr, cert] end |