renewal: fix key_type not being preserved on <v1.25.0 renewal configs (#9636)

Fixes #9635.
This commit is contained in:
alexzorin
2023-03-28 08:44:19 -07:00
committed by GitHub
parent 208ef4eb94
commit e10e549a95
5 changed files with 46 additions and 2 deletions
@@ -936,3 +936,24 @@ def test_preferred_chain(context: IntegrationTestsContext) -> None:
with open(conf_path, 'r') as f:
assert f'preferred_chain = {requested}' in f.read(), \
'Expected preferred_chain to be set in renewal config'
def test_ancient_rsa_key_type_preserved(context: IntegrationTestsContext) -> None:
certname = context.get_domain('newname')
context.certbot(['certonly', '-d', certname, '--key-type', 'rsa'])
assert_saved_lineage_option(context.config_dir, certname, 'key_type', 'rsa')
# Remove `key_type = rsa` from the renewal config to emulate a <v1.25.0 Certbot certificate.
conf_path = join(context.config_dir, 'renewal', f'{certname}.conf')
conf_contents: str = ''
with open(conf_path) as f:
conf_contents = f.read()
conf_contents = conf_contents.replace('key_type = rsa', '')
with open(conf_path, 'w') as f:
f.write(conf_contents)
context.certbot(['renew', '--cert-name', certname, '--force-renewal'])
assert_saved_lineage_option(context.config_dir, certname, 'key_type', 'rsa')
key2 = join(context.config_dir, 'archive/{0}/privkey2.pem'.format(certname))
assert_rsa_key(key2, 2048)