certmaker 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.md +19 -18
  2. data/bin/certmaker +43 -29
  3. metadata +2 -2
data/README.md CHANGED
@@ -9,7 +9,7 @@ This project is at an early stage. It is 100% usable for people who use Namechea
9
9
  ### Usage
10
10
  The typical usage is to create a private key locally and a CSR
11
11
 
12
- certmaker create your.secure.domain
12
+ certmaker create www.example.com
13
13
 
14
14
  You then keep the private key safe and use the CSR to request an SSL cert from your SSL Certificate provider
15
15
 
@@ -17,21 +17,20 @@ For some platforms the cert you receive from your SSL Certificate provider is al
17
17
 
18
18
  For other platforms (eg. heroku) you need to do a little more, such as combining together your key, certifice, intermediate cert chain as well as removing passwords.
19
19
 
20
- For heroku you just save the SSL cert zip in designated directory and run the commands...
20
+ For Namecheap Comodo PositiveSSL certs with heroku you just save the SSL cert zip in SSL provider artifact directory (eg. ~/.certmaker/certs/www_example_com_ssl/2_ssl_provider_artifacts/zips ) and run the commands...
21
21
 
22
- certmaker unpack_namecheap your.secure.domain
23
- certmaker heroku_wizard your.secure.domain
22
+ certmaker unpack_namecheap www.example.com
23
+ certmaker heroku_wizard www.example.com
24
24
 
25
25
  ... to do all that is necessary (currently we only can vouch for this process working with namecheap.com Comodo PositiveSSL certs as it all we have tested with). This will do the necessary transformations and then prompt you to upload the finished SSL cert to your heroku app.
26
26
 
27
27
  We also provide the following commands
28
28
 
29
- certmaker unpack_namecheap your.secure.domain
30
- certmaker combine_key your.secure.domain # can take an optional --certfilename parameter
31
- certmaker remove_passphrases your.secure.domain
32
- certmaker append_chain your.secure.domain
33
- certmaker check_chain your.secure.domain
34
- certmaker upload_to_heroku your.secure.domain
29
+ certmaker unpack_namecheap www.example.com
30
+ certmaker remove_passphrases www.example.com
31
+ certmaker append_chain www.example.com
32
+ certmaker check_chain www.example.com
33
+ certmaker upload_to_heroku www.example.com
35
34
 
36
35
  All your keys, certs and other details are stored under a .certmaker directory in your home directory. You need to have a little understanding of the directory stucture to know where to find things. Each cert you generate will live in its own directory under .certmaker/certs/
37
36
 
@@ -39,24 +38,26 @@ For example...
39
38
 
40
39
  /home/user/.certmaker/
41
40
  `-- certs
42
- `-- www_sample_com_ssl
41
+ `-- www_example_com_ssl
43
42
  |-- 1_my_key_and_csr
44
- | |-- www.sample.com.csr
45
- | `-- www.sample.com.key
43
+ | |-- www.example.com.csr
44
+ | `-- www.example.com.key
46
45
  |-- 2_ssl_provider_artifacts
47
46
  | `-- zips
48
- |-- 3_key_cert_combo
49
- |-- 4_key_cert_nopass
50
- |-- 5_key_cert_no_pass_chained
47
+ |-- 3_key_and_cert_nopass
48
+ |-- 4_key_and_cert_nopass_chained
51
49
  `-- config.yml
52
50
 
53
51
  ... your private key and CSR will be under 1_my_key_and_csr
54
52
 
55
- Note: The first time you run a command such as 'certmaker create your.secure.domain' for a new subdomain you will be prompted to create a config.yml file under the individual cert directory. Currently this config file is only used to supply the 'ordered_chain_filenames' setting. This allows you to define the order in which intermediate certs are chained together (yes, this all does sound unnecessarily confusing!).
53
+ Note: The first time you run a command such as 'certmaker create www.example.com' for a new subdomain you will be prompted to create a config.yml file under the individual cert directory. Currently this config file is only used to supply the 'ordered_chain_filenames' setting. This allows you to define the order in which intermediate certs are chained together (yes, this all does sound unnecessarily confusing!).
56
54
 
57
55
  The 2_ssl_provider_artifacts directory is used to store the cert and other bits send on by your SSL certificate provider after you have successfully applied for a cert (zip files should be stored in the zips folder).
58
56
 
59
- The 3_key_cert_combo is used to store files that combine a private key and a cert. The 4_key_cert_nopass directory transforms the contents of the previous directory so that any password has been remove from the files. This is often required so that cloud servers can automatically restart your app without needing to supply a password. Finally the 5_key_cert_no_pass_chained transforms the files a little more - ultimately it contains the final version of the cert by adding the intermediate chain. So by this stage we should have our SSL cert (with the key combined, any passwords removed and the intermediate chain added). Phew!
57
+ The 3_key_cert_nopass directory contains a copy of your private key and your ssl cert of with any passwords removed in case you had supplied any. This is often required so that cloud servers can automatically restart your app without needing to supply a password. Finally the 4_key_and_cert_nopass_chained transforms the files a little more - ultimately it contains the final version of the cert by adding the intermediate chain. So by this stage we should have our SSL cert (with any passwords removed and the intermediate chain added). Phew!
58
+
59
+ ###Issues
60
+ Please log any issues at https://github.com/theirishpenguin/certmaker/issues
60
61
 
61
62
  ###Credits
62
63
  Thanks to the following resources which laid the the foundation for this gem
@@ -40,7 +40,7 @@ end
40
40
  @exe_filepath = File.expand_path(__FILE__)
41
41
  @command = ARGV[0]
42
42
 
43
- @commands = ['create', 'unpack_namecheap', 'combine_key', 'remove_passphrases', 'append_chain', 'check_chain', 'upload_to_heroku', 'heroku_wizard'] # 'assemble_chain'
43
+ @commands = ['create', 'unpack_namecheap', 'remove_passphrases', 'append_chain', 'check_chain', 'upload_to_heroku', 'heroku_wizard'] # 'assemble_chain'
44
44
 
45
45
  unless @commands.include? @command
46
46
  puts "
@@ -87,6 +87,9 @@ Please create a config file at
87
87
  Here is a sample:
88
88
 
89
89
  #{sample_config_text}
90
+
91
+ Then rerun this command: #{PROGRAM_NAME} create #{@common_name}
92
+
90
93
  "
91
94
  exit 1
92
95
  end
@@ -114,11 +117,10 @@ def create_wip_dirs
114
117
  @dir1 ="#{@cert_dir}/1_my_key_and_csr"
115
118
  @dir2 = "#{@cert_dir}/2_ssl_provider_artifacts"
116
119
  @dir2_zips = "#{@dir2}/zips"
117
- @dir3 = "#{@cert_dir}/3_key_cert_combo"
118
- @dir4 = "#{@cert_dir}/4_key_cert_nopass"
119
- @dir5 = "#{@cert_dir}/5_key_cert_no_pass_chained"
120
+ @dir3 = "#{@cert_dir}/3_key_and_cert_nopass"
121
+ @dir4 = "#{@cert_dir}/4_key_and_cert_nopass_chained"
120
122
 
121
- [@dir1, @dir2_zips, @dir3, @dir4, @dir5].each do |dir|
123
+ [@dir1, @dir2_zips, @dir3, @dir4].each do |dir|
122
124
  FileUtils.mkdir_p dir
123
125
  end
124
126
 
@@ -129,7 +131,7 @@ def private_key_filepath
129
131
  end
130
132
 
131
133
  def private_key_nopass_filepath
132
- "#{@dir4}/#{@common_name}.nopass.key"
134
+ "#{@dir3}/#{@common_name}.nopass.key"
133
135
  end
134
136
 
135
137
  def csr_filepath
@@ -144,16 +146,12 @@ def crt_filepath
144
146
  end
145
147
  end
146
148
 
147
- def key_cert_combo_filepath
148
- "#{@dir3}/#{underscored_name}.pem"
149
- end
150
-
151
- def key_cert_combo_nopass_filepath
152
- "#{@dir4}/#{underscored_name}.nopass.pem"
149
+ def cert_nopass_filepath
150
+ "#{@dir3}/#{underscored_name}.nopass.pem"
153
151
  end
154
152
 
155
- def key_cert_combo_nopass_chained_filepath
156
- "#{@dir5}/#{underscored_name}_chained.nopass.pem"
153
+ def cert_nopass_chained_filepath
154
+ "#{@dir4}/#{underscored_name}_chained.nopass.pem"
157
155
  end
158
156
 
159
157
  def generate_private_key
@@ -183,6 +181,7 @@ Here's an example of values for your csr when asked.
183
181
  end
184
182
 
185
183
  def create
184
+ warn_if_private_key_already_exists
186
185
  generate_private_key
187
186
  display_csr_instructions
188
187
  generate_csr
@@ -194,9 +193,28 @@ def continue_prompt
194
193
  dummy = STDIN.gets.chomp
195
194
  end
196
195
 
196
+ def warn_if_private_key_already_exists
197
+ if File.exist?(private_key_filepath)
198
+ puts "
199
+
200
+ WARNING: A private key already for this domain at:
201
+
202
+ #{private_key_filepath}
203
+
204
+ Continuing will destroy this private key, which cannot be recovered unless
205
+ you have a backup of it. Are you sure you wish to continue?
206
+
207
+ "
208
+ continue_prompt
209
+ end
210
+ end
197
211
 
198
212
  def display_make_summary
199
213
  puts "
214
+
215
+
216
+ ###############################################################################
217
+
200
218
  A private key (.key file) and a CSR (.csr file) has been generated for you.
201
219
 
202
220
  The private key file is at
@@ -227,7 +245,6 @@ If your certs don't come in a zip file or your prefer to extract them manually b
227
245
  Once unpacked, you now have obtained your certs. Next up you can do any of the following as needed
228
246
 
229
247
  #{PROGRAM_NAME} heroku_wizard #{@common_name}
230
- #{PROGRAM_NAME} combine_key #{@common_name}
231
248
  #{PROGRAM_NAME} remove_passphrases #{@common_name}
232
249
  #{PROGRAM_NAME} append_chain #{@common_name}
233
250
  #{PROGRAM_NAME} check_chain #{@common_name}
@@ -248,18 +265,12 @@ def unpack_namecheap
248
265
  end
249
266
 
250
267
 
251
- def combine_private_key_and_cert
252
- instruct "Combining your private key with your combined cert"
253
-
254
- `cat #{crt_filepath} #{private_key_filepath} > #{key_cert_combo_filepath}`
255
- end
256
-
257
268
  def remove_passphrases
258
269
  instruct "Removing passphrase"
259
270
 
260
- puts `openssl rsa -in #{key_cert_combo_filepath} -out #{key_cert_combo_nopass_filepath}`
271
+ puts `openssl rsa -in #{crt_filepath} -out #{cert_nopass_filepath}`
261
272
 
262
- puts `openssl x509 -in #{key_cert_combo_filepath} >> #{key_cert_combo_nopass_filepath}`
273
+ puts `openssl x509 -in #{crt_filepath} >> #{cert_nopass_filepath}`
263
274
 
264
275
  puts `openssl rsa -in #{private_key_filepath} -out #{private_key_nopass_filepath}`
265
276
  end
@@ -273,7 +284,7 @@ end
273
284
  def append_chain
274
285
  instruct "Appending intermediate chain to cert"
275
286
 
276
- `cat #{key_cert_combo_nopass_filepath} #{chain_files_in_order} > #{key_cert_combo_nopass_chained_filepath}`
287
+ `cat #{cert_nopass_filepath} #{chain_files_in_order} > #{cert_nopass_chained_filepath}`
277
288
  end
278
289
 
279
290
  def check_chain
@@ -286,7 +297,7 @@ def check_chain
286
297
 
287
298
  instruct "Checking chain. The issuer of the first should be the subject of the second. And so on. Is that how the following output looks"
288
299
 
289
- puts `perl -n0777e 'map { print "---\n"; open(CMD, "| openssl x509 -noout -subject -issuer"); print CMD; close(CMD) } /^-----BEGIN.*?^-----END.*?\n/gsm' #{key_cert_combo_nopass_chained_filepath}`
300
+ puts `perl -n0777e 'map { print "---\n"; open(CMD, "| openssl x509 -noout -subject -issuer"); print CMD; close(CMD) } /^-----BEGIN.*?^-----END.*?\n/gsm' #{cert_nopass_chained_filepath}`
290
301
  end
291
302
 
292
303
  def upload_to_heroku
@@ -294,13 +305,19 @@ def upload_to_heroku
294
305
  puts "What is your heroku app name?"
295
306
  app_name = STDIN.gets.chomp
296
307
 
297
- cmd = "heroku ssl:add #{key_cert_combo_nopass_chained_filepath} #{private_key_nopass_filepath} --app #{app_name}"
308
+ cmd = "heroku ssl:add #{cert_nopass_chained_filepath} #{private_key_nopass_filepath} --app #{app_name}"
298
309
 
299
310
  puts "
311
+ Please ensure that you have a Custom Domain for #{@common_name} setup on your Heroku app before continuing.
312
+
300
313
  If you want to upload the key certificate to heroku for your app, this will run the command
301
314
 
302
315
  #{cmd}
303
316
 
317
+ If anything goes wrong at this stage you can simply run the following command to retry later
318
+
319
+ #{PROGRAM_NAME} upload_to_heroku #{@common_name}
320
+
304
321
  "
305
322
 
306
323
  continue_prompt
@@ -320,12 +337,9 @@ when 'create'
320
337
  create
321
338
  when 'unpack_namecheap'
322
339
  unpack_namecheap
323
- when 'combine_key'
324
- combine_private_key_and_cert
325
340
  when 'remove_passphrases'
326
341
  remove_passphrases
327
342
  when 'heroku_wizard'
328
- combine_private_key_and_cert
329
343
  remove_passphrases
330
344
  append_chain
331
345
  upload_to_heroku
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: certmaker
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Declan McGrath
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-18 00:00:00 Z
13
+ date: 2012-01-18 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: Easy way to make SSL Certs suitable for cloud platforms