r509-middleware-certwriter 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -0
- data/Rakefile +36 -0
- data/doc/R509.html +117 -0
- data/doc/R509/Middleware.html +117 -0
- data/doc/R509/Middleware/Certwriter.html +339 -0
- data/doc/_index.html +140 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +95 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +95 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +68 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/r509/middleware/certwriter.rb +57 -0
- data/lib/r509/middleware/certwriter/version.rb +7 -0
- data/spec/fixtures.rb +16 -0
- data/spec/fixtures/cert1.pem +24 -0
- data/spec/fixtures/san.pem +26 -0
- data/spec/fixtures/utf.pem +21 -0
- data/spec/fixtures/wildcard.pem +22 -0
- data/spec/middleware_spec.rb +188 -0
- data/spec/spec_helper.rb +16 -0
- metadata +142 -0
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# r509-middleware-certwriter
|
2
|
+
|
3
|
+
This project is related to [r509](http://github.com/reaperhulk/r509) and [r509-ca-http](http://github.com/sirsean/r509-ca-http), allowing us to save all issued certificates to the filesystem after they're issued. This is middleware so that you don't **need** to have your CA know anything about writing to the filesystem if you don't want to.
|
4
|
+
|
5
|
+
# config.ru
|
6
|
+
|
7
|
+
require 'r509/middleware/certwriter'
|
8
|
+
|
9
|
+
use R509::Middleware::Certwriter
|
10
|
+
run R509::CertificateAuthority::Http::Server
|
11
|
+
|
12
|
+
# config.yaml
|
13
|
+
|
14
|
+
You need to tell your CA where to save the issued certificates. Add this to the bottom of your ```config.yaml``` from **r509-ca-http**:
|
15
|
+
|
16
|
+
certwriter: {
|
17
|
+
path: "/absolute/path/to/wherever/you/want/the/certs"
|
18
|
+
}
|
19
|
+
|
20
|
+
Now every time a certificate is issued, it will be saved to the filesystem.
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require "#{File.dirname(__FILE__)}/lib/r509/middleware/certwriter/version"
|
4
|
+
|
5
|
+
task :default => :spec
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
desc 'Run all rspec tests with rcov (1.8 only)'
|
9
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
10
|
+
t.rcov_opts = %q[--exclude "spec,gems"]
|
11
|
+
t.rcov = true
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :gem do
|
15
|
+
desc 'Build the gem'
|
16
|
+
task :build do
|
17
|
+
puts `yard`
|
18
|
+
puts `gem build r509-middleware-certwriter.gemspec`
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Install gem'
|
22
|
+
task :install do
|
23
|
+
puts `gem install r509-middleware-certwriter-#{R509::Middleware::Certwriter::VERSION}.gem`
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Uninstall gem'
|
27
|
+
task :uninstall do
|
28
|
+
puts `gem uninstall r509-middleware-certwriter`
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Build yard documentation'
|
33
|
+
task :yard do
|
34
|
+
puts `yard`
|
35
|
+
`open doc/index.html`
|
36
|
+
end
|
data/doc/R509.html
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: R509
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.3
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index (R)</a> »
|
35
|
+
|
36
|
+
|
37
|
+
<span class="title">R509</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Module: R509
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<dt class="r1 last">Defined in:</dt>
|
82
|
+
<dd class="r1 last">lib/r509/middleware/certwriter.rb<span class="defines">,<br />
|
83
|
+
lib/r509/middleware/certwriter/version.rb</span>
|
84
|
+
</dd>
|
85
|
+
|
86
|
+
</dl>
|
87
|
+
<div class="clear"></div>
|
88
|
+
|
89
|
+
<h2>Defined Under Namespace</h2>
|
90
|
+
<p class="children">
|
91
|
+
|
92
|
+
|
93
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="R509/Middleware.html" title="R509::Middleware (module)">Middleware</a></span>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
</p>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div id="footer">
|
111
|
+
Generated on Thu Nov 8 14:21:12 2012 by
|
112
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
|
+
0.8.3 (ruby-1.9.3).
|
114
|
+
</div>
|
115
|
+
|
116
|
+
</body>
|
117
|
+
</html>
|
@@ -0,0 +1,117 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: R509::Middleware
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.3
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../';
|
20
|
+
framesUrl = "../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../_index.html">Index (M)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../R509.html" title="R509 (module)">R509</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Middleware</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Module: R509::Middleware
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
<dt class="r1 last">Defined in:</dt>
|
82
|
+
<dd class="r1 last">lib/r509/middleware/certwriter.rb<span class="defines">,<br />
|
83
|
+
lib/r509/middleware/certwriter/version.rb</span>
|
84
|
+
</dd>
|
85
|
+
|
86
|
+
</dl>
|
87
|
+
<div class="clear"></div>
|
88
|
+
|
89
|
+
<h2>Defined Under Namespace</h2>
|
90
|
+
<p class="children">
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Middleware/Certwriter.html" title="R509::Middleware::Certwriter (class)">Certwriter</a></span>
|
96
|
+
|
97
|
+
|
98
|
+
</p>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<div id="footer">
|
111
|
+
Generated on Thu Nov 8 14:21:12 2012 by
|
112
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
113
|
+
0.8.3 (ruby-1.9.3).
|
114
|
+
</div>
|
115
|
+
|
116
|
+
</body>
|
117
|
+
</html>
|
@@ -0,0 +1,339 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Class: R509::Middleware::Certwriter
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.3
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '../../';
|
20
|
+
framesUrl = "../../frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (C)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../R509.html" title="R509 (module)">R509</a></span></span> » <span class='title'><span class='object_link'><a href="../Middleware.html" title="R509::Middleware (module)">Middleware</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Certwriter</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="../../class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="../../method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="../../file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Class: R509::Middleware::Certwriter
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
<dt class="r1">Inherits:</dt>
|
75
|
+
<dd class="r1">
|
76
|
+
<span class="inheritName">Object</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">R509::Middleware::Certwriter</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
<dt class="r2">Includes:</dt>
|
94
|
+
<dd class="r2">Dependo::Mixin</dd>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<dt class="r1 last">Defined in:</dt>
|
101
|
+
<dd class="r1 last">lib/r509/middleware/certwriter.rb<span class="defines">,<br />
|
102
|
+
lib/r509/middleware/certwriter/version.rb</span>
|
103
|
+
</dd>
|
104
|
+
|
105
|
+
</dl>
|
106
|
+
<div class="clear"></div>
|
107
|
+
|
108
|
+
|
109
|
+
<h2>Constant Summary</h2>
|
110
|
+
|
111
|
+
<dl class="constants">
|
112
|
+
|
113
|
+
<dt id="VERSION-constant" class="">VERSION =
|
114
|
+
|
115
|
+
</dt>
|
116
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>0.1</span><span class='tstring_end'>"</span></span></pre></dd>
|
117
|
+
|
118
|
+
</dl>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<h2>
|
129
|
+
Instance Method Summary
|
130
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
131
|
+
</h2>
|
132
|
+
|
133
|
+
<ul class="summary">
|
134
|
+
|
135
|
+
<li class="public ">
|
136
|
+
<span class="summary_signature">
|
137
|
+
|
138
|
+
<a href="#call-instance_method" title="#call (instance method)">- (Object) <strong>call</strong>(env) </a>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
</span>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
153
|
+
|
154
|
+
</li>
|
155
|
+
|
156
|
+
|
157
|
+
<li class="public ">
|
158
|
+
<span class="summary_signature">
|
159
|
+
|
160
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Certwriter) <strong>initialize</strong>(app, config = nil) </a>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
</span>
|
165
|
+
|
166
|
+
|
167
|
+
<span class="note title constructor">constructor</span>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
<span class="summary_desc"><div class='inline'>
|
177
|
+
<p>A new instance of Certwriter.</p>
|
178
|
+
</div></span>
|
179
|
+
|
180
|
+
</li>
|
181
|
+
|
182
|
+
|
183
|
+
</ul>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
<div id="constructor_details" class="method_details_list">
|
188
|
+
<h2>Constructor Details</h2>
|
189
|
+
|
190
|
+
<div class="method_details first">
|
191
|
+
<h3 class="signature first" id="initialize-instance_method">
|
192
|
+
|
193
|
+
- (<tt><span class='object_link'><a href="" title="R509::Middleware::Certwriter (class)">Certwriter</a></span></tt>) <strong>initialize</strong>(app, config = nil)
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
</h3><div class="docstring">
|
200
|
+
<div class="discussion">
|
201
|
+
|
202
|
+
<p>A new instance of Certwriter</p>
|
203
|
+
|
204
|
+
|
205
|
+
</div>
|
206
|
+
</div>
|
207
|
+
<div class="tags">
|
208
|
+
|
209
|
+
|
210
|
+
</div><table class="source_code">
|
211
|
+
<tr>
|
212
|
+
<td>
|
213
|
+
<pre class="lines">
|
214
|
+
|
215
|
+
|
216
|
+
9
|
217
|
+
10
|
218
|
+
11
|
219
|
+
12
|
220
|
+
13
|
221
|
+
14
|
222
|
+
15
|
223
|
+
16
|
224
|
+
17</pre>
|
225
|
+
</td>
|
226
|
+
<td>
|
227
|
+
<pre class="code"><span class="info file"># File 'lib/r509/middleware/certwriter.rb', line 9</span>
|
228
|
+
|
229
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_app'>app</span><span class='comma'>,</span> <span class='id identifier rubyid_config'>config</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
230
|
+
<span class='ivar'>@app</span> <span class='op'>=</span> <span class='id identifier rubyid_app'>app</span>
|
231
|
+
|
232
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_config'>config</span>
|
233
|
+
<span class='ivar'>@config</span> <span class='op'>=</span> <span class='const'>YAML</span><span class='period'>.</span><span class='id identifier rubyid_load_file'>load_file</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>config.yaml</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
234
|
+
<span class='kw'>else</span>
|
235
|
+
<span class='ivar'>@config</span> <span class='op'>=</span> <span class='id identifier rubyid_config'>config</span>
|
236
|
+
<span class='kw'>end</span>
|
237
|
+
<span class='kw'>end</span></pre>
|
238
|
+
</td>
|
239
|
+
</tr>
|
240
|
+
</table>
|
241
|
+
</div>
|
242
|
+
|
243
|
+
</div>
|
244
|
+
|
245
|
+
|
246
|
+
<div id="instance_method_details" class="method_details_list">
|
247
|
+
<h2>Instance Method Details</h2>
|
248
|
+
|
249
|
+
|
250
|
+
<div class="method_details first">
|
251
|
+
<h3 class="signature first" id="call-instance_method">
|
252
|
+
|
253
|
+
- (<tt>Object</tt>) <strong>call</strong>(env)
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
</h3><table class="source_code">
|
260
|
+
<tr>
|
261
|
+
<td>
|
262
|
+
<pre class="lines">
|
263
|
+
|
264
|
+
|
265
|
+
19
|
266
|
+
20
|
267
|
+
21
|
268
|
+
22
|
269
|
+
23
|
270
|
+
24
|
271
|
+
25
|
272
|
+
26
|
273
|
+
27
|
274
|
+
28
|
275
|
+
29
|
276
|
+
30
|
277
|
+
31
|
278
|
+
32
|
279
|
+
33
|
280
|
+
34
|
281
|
+
35
|
282
|
+
36
|
283
|
+
37
|
284
|
+
38
|
285
|
+
39
|
286
|
+
40
|
287
|
+
41
|
288
|
+
42
|
289
|
+
43
|
290
|
+
44
|
291
|
+
45</pre>
|
292
|
+
</td>
|
293
|
+
<td>
|
294
|
+
<pre class="code"><span class="info file"># File 'lib/r509/middleware/certwriter.rb', line 19</span>
|
295
|
+
|
296
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
297
|
+
<span class='id identifier rubyid_status'>status</span><span class='comma'>,</span> <span class='id identifier rubyid_headers'>headers</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span> <span class='op'>=</span> <span class='ivar'>@app</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
298
|
+
|
299
|
+
<span class='comment'># we only care about issuance, and we just want to pull out the cert and write it to disk
|
300
|
+
</span> <span class='kw'>if</span> <span class='kw'>not</span> <span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>PATH_INFO</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\/1\/certificate\/issue\/?$</span><span class='regexp_end'>/</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='kw'>and</span> <span class='id identifier rubyid_status'>status</span> <span class='op'>==</span> <span class='int'>200</span>
|
301
|
+
<span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span>
|
302
|
+
<span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_part'>part</span><span class='op'>|</span>
|
303
|
+
<span class='id identifier rubyid_body'>body</span> <span class='op'>+=</span> <span class='id identifier rubyid_part'>part</span>
|
304
|
+
<span class='kw'>end</span>
|
305
|
+
<span class='kw'>begin</span>
|
306
|
+
<span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_params'>parse_params</span><span class='lparen'>(</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
307
|
+
<span class='id identifier rubyid_cert'>cert</span> <span class='op'>=</span> <span class='const'>R509</span><span class='op'>::</span><span class='const'>Cert</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:cert</span> <span class='op'>=></span> <span class='id identifier rubyid_body'>body</span><span class='rparen'>)</span>
|
308
|
+
<span class='id identifier rubyid_file_path'>file_path</span> <span class='op'>=</span> <span class='ivar'>@config</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>certwriter</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>path</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span>
|
309
|
+
<span class='id identifier rubyid_filename'>filename</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_file_path'>file_path</span><span class='comma'>,</span>
|
310
|
+
<span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cert'>cert</span><span class='period'>.</span><span class='id identifier rubyid_subject_component'>subject_component</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>CN</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='rbrace'>}</span><span class='tstring_content'>_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ca</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cert'>cert</span><span class='period'>.</span><span class='id identifier rubyid_serial'>serial</span><span class='rbrace'>}</span><span class='tstring_content'>.pem</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span>
|
311
|
+
<span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>*</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>STAR</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='period'>.</span>
|
312
|
+
<span class='id identifier rubyid_encode'>encode</span><span class='lparen'>(</span><span class='const'>Encoding</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>ASCII</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:invalid</span> <span class='op'>=></span> <span class='symbol'>:replace</span><span class='comma'>,</span> <span class='symbol'>:undef</span> <span class='op'>=></span> <span class='symbol'>:replace</span><span class='comma'>,</span> <span class='symbol'>:replace</span> <span class='op'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:universal_newline</span> <span class='op'>=></span> <span class='kw'>true</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
313
|
+
<span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Writing: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_filename'>filename</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span>
|
314
|
+
<span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='id identifier rubyid_filename'>filename</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>w</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_cert'>cert</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span><span class='rbrace'>}</span>
|
315
|
+
<span class='kw'>rescue</span> <span class='op'>=></span> <span class='id identifier rubyid_e'>e</span>
|
316
|
+
<span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Writing failed</span><span class='tstring_end'>"</span></span>
|
317
|
+
<span class='id identifier rubyid_log'>log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span>
|
318
|
+
<span class='kw'>end</span>
|
319
|
+
<span class='kw'>end</span>
|
320
|
+
|
321
|
+
<span class='lbracket'>[</span><span class='id identifier rubyid_status'>status</span><span class='comma'>,</span> <span class='id identifier rubyid_headers'>headers</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span><span class='rbracket'>]</span>
|
322
|
+
<span class='kw'>end</span></pre>
|
323
|
+
</td>
|
324
|
+
</tr>
|
325
|
+
</table>
|
326
|
+
</div>
|
327
|
+
|
328
|
+
</div>
|
329
|
+
|
330
|
+
</div>
|
331
|
+
|
332
|
+
<div id="footer">
|
333
|
+
Generated on Thu Nov 8 14:21:12 2012 by
|
334
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
335
|
+
0.8.3 (ruby-1.9.3).
|
336
|
+
</div>
|
337
|
+
|
338
|
+
</body>
|
339
|
+
</html>
|