Skip to content

Commit cec1cfc

Browse files
committed
Remove OCSP support.
See https://letsencrypt.org/2024/12/05/ending-ocsp/ for details.
1 parent 4af2a82 commit cec1cfc

File tree

8 files changed

+11
-124
lines changed

8 files changed

+11
-124
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ With the yaml snippet above you'd request the following certificates:
148148
149149
# /usr/lib/nagios/plugins/check_statusfile /opt/dehydrated/monitoring.status
150150
dehydrated certificates: OK: 2, FAILED: 1
151-
foo.example.com (from bar.example.com): OCSP update failed
151+
foo.example.com (from bar.example.com): some error description
152152
153153
154154
## Migrating from _bzed-letsencrypt_

REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* `dehydrated::certificate::deploy`: Deploy collected certificate and CA files.
3131
* `dehydrated::certificate::dh`: Create the DH params file.
3232
* `dehydrated::certificate::request`: Prepare everything to request a certifificate for our CSRs.
33-
* `dehydrated::certificate::transfer`: Transfer crt/ca/ocsp files.
33+
* `dehydrated::certificate::transfer`: Transfer crt/ca files.
3434

3535
### Resource types
3636

files/dehydrated_job_runner.rb

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -83,70 +83,6 @@ def update_ca_chain(crt_file, ca_file)
8383
[stdout, stderr, status]
8484
end
8585

86-
def update_ocsp(ocsp_file, crt_file, ca_file)
87-
crt = OpenSSL::X509::Certificate.new(File.read(crt_file))
88-
ca = OpenSSL::X509::Certificate.new(File.read(ca_file))
89-
digest = OpenSSL::Digest::SHA1.new
90-
certificate_id = OpenSSL::OCSP::CertificateId.new(crt, ca, digest)
91-
request = OpenSSL::OCSP::Request.new
92-
request.add_certid certificate_id
93-
94-
# seems LE doesn't handle nonces.
95-
# request.add_nonce
96-
97-
ocsp_uri = _get_authority_url(crt, 'OCSP')
98-
99-
ocsp_response = ''
100-
limit = 10
101-
while limit > 0
102-
path = if ocsp_uri.path.empty?
103-
'/'
104-
else
105-
ocsp_uri.path
106-
end
107-
response = Net::HTTP.start ocsp_uri.hostname, ocsp_uri.port do |http|
108-
http.post(
109-
path,
110-
request.to_der,
111-
'content-type' => 'application/ocsp-request',
112-
)
113-
end
114-
case response
115-
when Net::HTTPSuccess then
116-
ocsp_response = response.body
117-
status = 0
118-
stdout = ''
119-
stderr = response.message
120-
when Net::HTTPRedirection then
121-
ocsp_uri = URI(response['location'])
122-
limit -= 1
123-
status = response.code
124-
stdout = response.body
125-
stderr = response.message
126-
next
127-
else
128-
status = 1
129-
stdout = ''
130-
stderr = response.class.name
131-
end
132-
break
133-
end
134-
135-
if status.zero? && ocsp_response != ''
136-
ocsp = OpenSSL::OCSP::Response.new ocsp_response
137-
store = OpenSSL::X509::Store.new
138-
store.add_cert(ca)
139-
140-
if ocsp.basic # && ocsp.basic().verify([], store)
141-
File.write(ocsp_file, ocsp.to_der)
142-
else
143-
status = 1
144-
stderr = stdout = 'OCSP verification failed'
145-
end
146-
end
147-
[stdout, stderr, status.to_i]
148-
end
149-
15086
def register_account(dehydrated_config)
15187
run_dehydrated(dehydrated_config, '--accept-terms --register')
15288
end
@@ -236,7 +172,6 @@ def handle_request(fqdn, dn, config)
236172
csr_content = config['csr_content']
237173
csr_file = File.join(request_base_dir, "#{base_filename}.csr")
238174
ca_file = File.join(request_base_dir, "#{base_filename}_ca.pem")
239-
ocsp_file = "#{crt_file}.ocsp"
240175
subject_alternative_names = config['subject_alternative_names'].sort.uniq
241176
dehydrated_domain_validation_hook_script = config['dehydrated_domain_validation_hook_script']
242177
dehydrated_hook_script = config['dehydrated_hook_script']
@@ -253,6 +188,10 @@ def handle_request(fqdn, dn, config)
253188
new_dn_config
254189
end
255190

191+
# clean up OCSP files as they are not supported by letsencrypt anymore.
192+
ocsp_file = "#{crt_file}.ocsp"
193+
File.delete(ocsp_file) if File.exist?(ocsp_file)
194+
256195
# register / update account
257196
# prior to 2024-04, the config did not contain the request_account_dir. Fall back to the
258197
# previous method if we don't have request_account_dir in the config (yet?).
@@ -319,25 +258,12 @@ def handle_request(fqdn, dn, config)
319258
if status > 0 || !cert_still_valid(crt_file)
320259
return ['CSR signing failed', stdout, stderr, status] if status > 0
321260
end
322-
# remove ocsp file after getting a new certificate
323-
if status.zero? && File.exist?(ocsp_file)
324-
File.delete(ocsp_file)
325-
end
326261
end
327262

328263
# track currently used config
329264
# we do this before the OCSP stuff as we have a valid cert already.
330265
File.write(dn_config_file, JSON.generate(new_dn_config))
331266

332-
if cert_still_valid(crt_file)
333-
ocsp_uptodate = File.exist?(ocsp_file) &&
334-
(File.mtime(ocsp_file) + 24 * 60 * 60) > Time.now &&
335-
File.mtime(ocsp_file) > File.mtime(crt_file)
336-
unless ocsp_uptodate
337-
stdout, stderr, status = update_ocsp(ocsp_file, crt_file, ca_file)
338-
return ['OCSP update failed', stdout, stderr, status] if status > 0
339-
end
340-
end
341267
old_env.each do |key, value|
342268
ENV[key] = value
343269
end

lib/facter/dehydrated_certificates.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@
33
require 'openssl'
44
require 'base64'
55

6-
def get_ocsp(ocsp)
7-
if File.exist?(ocsp)
8-
Base64.strict_encode64(File.read(ocsp))
9-
else
10-
nil
11-
end
12-
end
13-
146
def get_file(filename)
157
if File.exist?(filename)
168
File.read(filename)
@@ -51,8 +43,6 @@ def handle_requests(config)
5143
ca_file = "#{request_base_dir}/#{base_filename}_ca.pem"
5244
requests[request_fqdn][dn]['ca'] = get_file(ca_file)
5345
end
54-
ocsp_file = "#{crt_file}.ocsp"
55-
requests[request_fqdn][dn]['ocsp'] = get_ocsp(ocsp_file)
5646
end
5747
end
5848
end

lib/puppet/functions/dehydrated/file.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ def getfile(files, *more_files)
1717
raise(Puppet::ParseError, 'Files must be fully qualified')
1818
end
1919
next unless File.exist?(file)
20-
ret = if %r{.*\.ocsp$}.match?(file)
21-
Base64.strict_encode64(File.read(file))
22-
else
23-
File.read(file)
24-
end
20+
ret = File.read(file)
2521
end
2622
ret
2723
end

manifests/certificate/collect.pp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
$dehydrated_requests_dir = $dehydrated::dehydrated_requests_dir
3232
$crt_file = "${request_base_dir}/${request_base_filename}.crt"
3333
$ca_file = "${request_base_dir}/${request_base_filename}_ca.pem"
34-
$ocsp_file = "${crt_file}.ocsp"
3534

3635
$crt = dehydrated::file($crt_file)
37-
$ocsp = dehydrated::file($ocsp_file)
3836
$ca = dehydrated::file($ca_file)
3937
} else {
4038
# we are on a non-puppetmaster host
@@ -50,14 +48,6 @@
5048
} else {
5149
$crt = undef
5250
}
53-
if (
54-
'ocsp' in $config and
55-
$config['ocsp'] =~ Stdlib::Base64
56-
) {
57-
$ocsp = String(Binary($config['ocsp']))
58-
} else {
59-
$ocsp = undef
60-
}
6151
if 'ca' in $config {
6252
$ca = $config['ca']
6353
} else {
@@ -66,7 +56,6 @@
6656
} else {
6757
notify { 'No dehydrated certificate config from facter :(' : }
6858
$crt = undef
69-
$ocsp = undef
7059
$ca = undef
7160
}
7261
}
@@ -89,13 +78,4 @@
8978
request_base_filename => $request_base_filename,
9079
}
9180
}
92-
if ($ocsp) {
93-
@@dehydrated::certificate::transfer { "${name}-transfer-ocsp" :
94-
file_type => 'ocsp',
95-
request_dn => $request_dn,
96-
request_fqdn => $request_fqdn,
97-
file_content => $ocsp,
98-
request_base_filename => $request_base_filename,
99-
}
100-
}
10181
}

manifests/certificate/transfer.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Used as exported ressource to ransfer crt/ca/ocsp files.
1+
# Used as exported ressource to ransfer crt/ca files.
22
#
3-
# @summary Transfer crt/ca/ocsp files.
3+
# @summary Transfer crt/ca files.
44
#
55
# @example
66
# dehydrated::certificate::transfer { 'namevar':
@@ -13,7 +13,7 @@
1313
# @api private
1414
#
1515
define dehydrated::certificate::transfer (
16-
Enum['crt', 'ca', 'ocsp'] $file_type,
16+
Enum['crt', 'ca'] $file_type,
1717
Dehydrated::DN $request_dn,
1818
Stdlib::Fqdn $request_fqdn,
1919
String $request_base_filename,

manifests/init.pp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,11 @@
252252

253253
$transfer_data = puppetdb_query($transfer_query)
254254
$transfer_data.each |$transfer| {
255-
if ($transfer['parameters.file_type'] == 'ocsp') {
256-
$content = base64('decode', $transfer['parameters.file_content'])
257-
} else {
258-
$content = $transfer['parameters.file_content']
259-
}
255+
$content = $transfer['parameters.file_content']
260256

261257
$filenames = {
262258
'ca' => "${crt_dir}/${_base_filename}_ca.pem",
263259
'crt' => "${crt_dir}/${_base_filename}.crt",
264-
'ocsp' => "${crt_dir}/${_base_filename}.crt.ocsp",
265260
}
266261

267262
$filename = $filenames[$transfer['parameters.file_type']]

0 commit comments

Comments
 (0)