eassl 0.1.1635 → 0.1.1643

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/eassl.rb +35 -0
  2. metadata +2 -2
@@ -1,3 +1,5 @@
1
+ require 'openssl'
2
+ require 'fileutils'
1
3
  $:.unshift File.expand_path(File.dirname(__FILE__))
2
4
  # = About EaSSL
3
5
  #
@@ -25,6 +27,39 @@ module EaSSL
25
27
  cert = ca.create_certificate(sr)
26
28
  [ca, sr, cert]
27
29
  end
30
+
31
+ def self.config_webrick(webrick_config, options = {})
32
+ hostname = `hostname`.strip
33
+ eassl_host_dir = "#{File.expand_path('~')}/.eassl/#{hostname}"
34
+ ca_cert_file = "#{eassl_host_dir}/ca.crt"
35
+ ca_key_file = "#{eassl_host_dir}/ca.key"
36
+ server_key_file = "#{eassl_host_dir}/server.key"
37
+ server_cert_file = "#{eassl_host_dir}/server.crt"
38
+ FileUtils.rm_rf(eassl_host_dir) if options[:force_regeneration]
39
+
40
+ if File.exist?(server_cert_file)
41
+ key = Key.load(server_key_file, 'countinghouse1234')
42
+ cert = Certificate.load(server_cert_file)
43
+ else
44
+ ca, sr, cert = self.generate_self_signed({:name => {:common_name => hostname}, :bits => 1024}.update(options))
45
+ key = sr.key
46
+ FileUtils.makedirs(eassl_host_dir)
47
+ File.open(%(#{ca_cert_file}.pem), "w", 0777) {|f| f << ca.certificate.to_pem }
48
+ File.open(%(#{ca_cert_file}.der), "w", 0777) {|f| f << ca.certificate.to_der }
49
+ File.open(ca_key_file, "w", 0777) {|f| f << ca.key.to_pem }
50
+ File.open(server_key_file, "w", 0777) {|f| f << key.to_pem }
51
+ File.open(server_cert_file, "w", 0777) {|f| f << cert.to_pem }
52
+ end
53
+
54
+ webrick_config.update({
55
+ :SSLEnable => true,
56
+ :SSLPrivateKey => key.ssl,
57
+ :SSLCertificate => cert.ssl,
58
+ :SSLExtraChainCert => [Certificate.load(%(#{ca_cert_file}.pem)).ssl],
59
+ :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
60
+ :SSLStartImmediately => true,
61
+ })
62
+ end
28
63
  end
29
64
 
30
65
  require 'eassl/key'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: eassl
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1635
7
- date: 2006-11-16 00:00:00 -05:00
6
+ version: 0.1.1643
7
+ date: 2006-11-17 00:00:00 -05:00
8
8
  summary: EaSSL is a library aimed at making openSSL certificate generation and management easier and more ruby-ish.
9
9
  require_paths:
10
10
  - lib