letscert 0.4.2 → 0.4.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81459818c78f3836b106c632ae5befa99dcacf82
4
- data.tar.gz: 1fce468a7511a75b84f584ff1fd8b5455db48065
3
+ metadata.gz: b1c7540da4fdf5cbdc335d39e2bbe3ddbdf1c626
4
+ data.tar.gz: 677697d448f263b70b20cea1d8b63e6a26a4db6b
5
5
  SHA512:
6
- metadata.gz: 3b4ce524f540fbb291c6c88f13d32bfa27a501c2105d8c5002ff98ef9d4c808802cdaecd7cbffad6e53695792b84ed180517d16facd079af245f960f9cce100a
7
- data.tar.gz: 2149c9cd3a620ecebf9d1ec2bdaaeef2f7f92944127c25f4351ecc42424503526c9fbf2d8498ad19b54277f76b301fe3a838eb96a3a7562745f69e08c60c4077
6
+ metadata.gz: fe59f20eabe2f24f06d64613668146bb18280fc0e78b1cb24560eff2eb6dce9a19319dea8806f1f4e06d1abf15338f67bd513be74a53650e66c7fe45d3e69424
7
+ data.tar.gz: 2bdc561629f525bea12e80ca1d5cace8ac851529be690ed8836dcd539c49e1243be9d0f745a8a9454b38431ad607cfe5e8cd11721975b7da6581c3ced2d41b13
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -70,11 +70,13 @@ module LetsCert
70
70
  end
71
71
 
72
72
  # @abstract This method must be overriden in subclasses
73
+ # Load data from disk
73
74
  def load
74
75
  raise NotImplementedError
75
76
  end
76
77
 
77
78
  # @abstract This method must be overriden in subclasses
79
+ # Save data to disk
78
80
  def save
79
81
  raise NotImplementedError
80
82
  end
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
 
3
24
  # Account key IO plugin
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
 
3
24
  # Cert file plugin
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
 
3
24
  # Chain file plugin
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
 
3
24
  # Mixin for IOPmugin subclasses that handle files
@@ -11,7 +32,7 @@ module LetsCert
11
32
 
12
33
  begin
13
34
  content = File.read(@name)
14
- rescue Errno::ENOENT => ex
35
+ rescue Errno::ENOENT
15
36
  logger.info { "no #{@name} file" }
16
37
  return self.class.empty_data
17
38
  end
@@ -29,6 +50,7 @@ module LetsCert
29
50
  # Save data to file +#name+
30
51
  # @param [Hash] data
31
52
  # @return [void]
53
+ # @raise [Error] IO error
32
54
  def save_to_file(data)
33
55
  return if data.nil?
34
56
 
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
 
3
24
  # Fullchain file plugin
@@ -21,16 +42,14 @@ module LetsCert
21
42
  chain = data[:chain]
22
43
  end
23
44
 
24
- { account_key: data[:account_key], key: data[:key], cert: cert,
25
- chain: chain }
45
+ { cert: cert, chain: chain }
26
46
  end
27
47
 
28
48
  # Save fullchain.
29
49
  # @param [Hash] data
30
50
  # @return [void]
31
51
  def save(data)
32
- super(account_key: data[:account_key], key: data[:key], cert: nil,
33
- chain: [data[:cert]] + data[:chain])
52
+ super(cert: nil, chain: [data[:cert]] + data[:chain])
34
53
  end
35
54
 
36
55
  end
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  require 'base64'
2
23
 
3
24
  module LetsCert
@@ -17,12 +38,19 @@ module LetsCert
17
38
  # @param [String] data
18
39
  # @return [String]
19
40
  def urlsafe_decode64(data)
20
- Base64.urlsafe_decode64(data.sub(/[\s=]*\z/, ''))
41
+ # Ruby < 2.3.0 urlsafe_decode64 use struct_decode64. So the string
42
+ # is rejected if padding is removed (which JWK do)
43
+ # So, we have to reinject padding
44
+ if !data.end_with?("=") && data.length % 4 != 0
45
+ data = data.ljust((data.length + 3) & ~3, "=")
46
+ end
47
+ Base64.urlsafe_decode64(data)
21
48
  end
22
49
 
23
50
  # Load crypto data from JSON-encoded file
24
51
  # @param [String] data JSON-encoded data
25
- # @return [OpenSSL::PKey::PKey]
52
+ # @return [OpenSSL::PKey::PKey,nil]
53
+ # @raise [Error] unsupported key type
26
54
  def load_jwk(data)
27
55
  return nil if data.empty?
28
56
 
@@ -45,12 +73,14 @@ module LetsCert
45
73
  # Dump crypto data (key) to a JSON-encoded string
46
74
  # @param [OpenSSL::PKey] key
47
75
  # @return [String]
76
+ # @raise [Error] unsupported key type
48
77
  def dump_jwk(key)
49
- return {}.to_json if key.nil?
78
+ h = {}
79
+ return h.to_json if key.nil?
50
80
 
51
- h = { 'kty' => 'RSA' }
52
81
  case key
53
82
  when OpenSSL::PKey::RSA
83
+ h['kty'] = 'RSA'
54
84
  h['e'] = urlsafe_encode64(key.e.to_s(2)) if key.e
55
85
  h['n'] = urlsafe_encode64(key.n.to_s(2)) if key.n
56
86
  if key.private?
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
 
3
24
  # Key file plugin
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
 
3
24
  # OpenSSL IOPlugin
@@ -9,6 +30,7 @@ module LetsCert
9
30
 
10
31
  # @param [String] name filename
11
32
  # @param [:pem,:der] type
33
+ # @raise [ArgumentError] unsupported type
12
34
  def initialize(name, type)
13
35
  case type
14
36
  when :pem
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
  class Runner
3
24
 
@@ -1,3 +1,24 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2016 Sylvain Daubert
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
1
22
  module LetsCert
2
23
  class Runner
3
24
 
@@ -1,6 +1,6 @@
1
1
  module LetsCert
2
2
 
3
3
  # Letscert version number
4
- VERSION = '0.4.2'.freeze
4
+ VERSION = '0.4.3'.freeze
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letscert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Daubert
@@ -31,7 +31,7 @@ cert_chain:
31
31
  dMi8WSKt03lfzyxIqZseBwVYYn+XMlzCcJLXCUgZXHcBRRRDH5wGDqOqXjL25b2O
32
32
  6m3JJngqkCFrOw==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-09-23 00:00:00.000000000 Z
34
+ date: 2016-10-12 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: acme-client
metadata.gz.sig CHANGED
Binary file