puppetserver-ca 2.3.2 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffcdb4b7a4972842dd5f3cc03d3879998e1ab8fcba4066d49e919a1ba6c7312c
4
- data.tar.gz: d32629c393a75fa5f6291e97bc84a4620738ef97804f569e031a4f975ac7b059
3
+ metadata.gz: 145cb62d733040dca7ad410a86146e0a0c82c29746a2c7de392004ad98737ed5
4
+ data.tar.gz: bd0db987a4af957208395f53134c3d59ab45f3c76d2e5d4205b589b75b1b9873
5
5
  SHA512:
6
- metadata.gz: aa99515bb8c32de7529d63bc4242bc4ef71ea8ba0c3f00137fa31cdec0a08e8b6da13d9daaaefd922e50abdbe287ced9ec2395802d4012754a4086c804d27907
7
- data.tar.gz: '059760fa95029609e65f15726944c342053f66ac092cafb2f073896d3e143caf7f7a3029642749001b3fb6a289cf78ffe26dfb56a33399c60d268a1b303609d3'
6
+ metadata.gz: d5ec57e3cfd1d2947521b50a2923892452f25c4ae43c0daa45e9a0ba17ebd969431933f17d71866ff8e9e15bcdeb633c754084c618ea8bd2b1891ae0438751a5
7
+ data.tar.gz: ebfc68d10303eea0d66b61a636b069986e6f4d65e1af4a222bfea5d74a45951edb2d6f01192f4d0bafdbe3392e80a356074c334212651d2489e5d2dae0e8120b
@@ -31,6 +31,7 @@ BANNER
31
31
 
32
32
  def run(inputs)
33
33
  config_path = inputs['config']
34
+ exit_code = 0
34
35
 
35
36
  # Validate the config path.
36
37
  if config_path
@@ -49,55 +50,59 @@ BANNER
49
50
  # Getting the CRL(s)
50
51
  loader = X509Loader.new(puppet.settings[:cacert], puppet.settings[:cakey], puppet.settings[:cacrl])
51
52
 
52
- puppet_crl = loader.crls.select { |crl| crl.verify(loader.key) }
53
- number_of_removed_duplicates = prune_CRLs(puppet_crl)
53
+ verified_crls = loader.crls.select { |crl| crl.verify(loader.key) }
54
54
 
55
- if number_of_removed_duplicates > 0
56
- update_pruned_CRL(puppet_crl, loader.key)
57
- FileSystem.write_file(puppet.settings[:cacrl], loader.crls, 0644)
58
- @logger.inform("Removed #{number_of_removed_duplicates} duplicated certs from Puppet's CRL.")
55
+ if verified_crls.length == 1
56
+ puppet_crl = verified_crls.first
57
+ @logger.inform("Total number of certificates found in Puppet's CRL is: #{puppet_crl.revoked.length}.")
58
+ number_of_removed_duplicates = prune_CRL(puppet_crl)
59
+
60
+ if number_of_removed_duplicates > 0
61
+ update_pruned_CRL(puppet_crl, loader.key)
62
+ FileSystem.write_file(puppet.settings[:cacrl], loader.crls, 0644)
63
+ @logger.inform("Removed #{number_of_removed_duplicates} duplicated certs from Puppet's CRL.")
64
+ else
65
+ @logger.inform("No duplicate revocations found in the CRL.")
66
+ end
59
67
  else
60
- @logger.inform("No duplicate revocations found in the CRL.")
68
+ @logger.err("Could not identify Puppet's CRL. Aborting prune action.")
69
+ exit_code = 1
61
70
  end
62
71
 
63
- return 0
72
+ return exit_code
64
73
  end
65
74
 
66
- def prune_CRLs(crl_list)
75
+ def prune_CRL(crl)
67
76
  number_of_removed_duplicates = 0
68
77
 
69
- crl_list.each do |crl|
70
- existed_serial_number = Set.new()
71
- revoked_list = crl.revoked
72
- @logger.debug("Pruning duplicate entries in CRL for issuer " \
73
- "#{crl.issuer.to_s(OpenSSL::X509::Name::RFC2253)}") if @logger.debug?
74
-
75
- revoked_list.delete_if do |revoked|
76
- if existed_serial_number.add?(revoked.serial)
77
- false
78
- else
79
- number_of_removed_duplicates += 1
80
- @logger.debug("Removing duplicate of #{revoked.serial}, " \
81
- "revoked on #{revoked.time}\n") if @logger.debug?
82
- true
83
- end
78
+ existed_serial_number = Set.new()
79
+ revoked_list = crl.revoked
80
+ @logger.debug("Pruning duplicate entries in CRL for issuer " \
81
+ "#{crl.issuer.to_s(OpenSSL::X509::Name::RFC2253)}") if @logger.debug?
82
+
83
+ revoked_list.delete_if do |revoked|
84
+ if existed_serial_number.add?(revoked.serial)
85
+ false
86
+ else
87
+ number_of_removed_duplicates += 1
88
+ @logger.debug("Removing duplicate of #{revoked.serial}, " \
89
+ "revoked on #{revoked.time}\n") if @logger.debug?
90
+ true
84
91
  end
85
- crl.revoked=(revoked_list)
86
92
  end
93
+ crl.revoked=(revoked_list)
87
94
 
88
95
  return number_of_removed_duplicates
89
96
  end
90
97
 
91
- def update_pruned_CRL(crl_list, pkey)
92
- crl_list.each do |crl|
93
- number_ext, other_ext = crl.extensions.partition{ |ext| ext.oid == "crlNumber" }
94
- number_ext.each do |crl_number|
95
- updated_crl_number = OpenSSL::BN.new(crl_number.value) + OpenSSL::BN.new(1)
96
- crl_number.value=(OpenSSL::ASN1::Integer(updated_crl_number))
97
- end
98
- crl.extensions=(number_ext + other_ext)
99
- crl.sign(pkey, OpenSSL::Digest::SHA256.new)
98
+ def update_pruned_CRL(crl, pkey)
99
+ number_ext, other_ext = crl.extensions.partition{ |ext| ext.oid == "crlNumber" }
100
+ number_ext.each do |crl_number|
101
+ updated_crl_number = OpenSSL::BN.new(crl_number.value) + OpenSSL::BN.new(1)
102
+ crl_number.value=(OpenSSL::ASN1::Integer(updated_crl_number))
100
103
  end
104
+ crl.extensions=(number_ext + other_ext)
105
+ crl.sign(pkey, OpenSSL::Digest::SHA256.new)
101
106
  end
102
107
 
103
108
  def self.parser(parsed = {})
@@ -141,7 +141,7 @@ module Puppetserver
141
141
  url = protocol + '://' + host + ':' + port + '/' +
142
142
  [endpoint, version, resource_type, resource_name].join('/')
143
143
 
144
- url = url + "?" + URI.encode_www_form(query) unless query.empty?
144
+ url = url + "?" + URI.encode_www_form(query) unless query.nil? || query.empty?
145
145
  return url
146
146
  end
147
147
 
@@ -1,5 +1,5 @@
1
1
  module Puppetserver
2
2
  module Ca
3
- VERSION = "2.3.2"
3
+ VERSION = "2.3.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetserver-ca
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-17 00:00:00.000000000 Z
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facter