diff --git a/certbot/certbot/_internal/main.py b/certbot/certbot/_internal/main.py index 87b7eddec..e77c56ac2 100644 --- a/certbot/certbot/_internal/main.py +++ b/certbot/certbot/_internal/main.py @@ -489,17 +489,19 @@ def _report_new_cert(config, cert_path, fullchain_path, key_path=None): assert cert_path and fullchain_path, "No certificates saved to report." - expiry = crypto_util.notAfter(cert_path).date() - display_util.notify( ("\nSuccessfully received certificate.\n" - "Certificate is saved at: {cert_path}\n{key_msg}{symlink_msg}" - "This certificate expires on {expiry}.").format( + "Certificate is saved at: {cert_path}\n{key_msg}" + "This certificate expires on {expiry}.\n" + "{renew_msg}\n").format( cert_path=fullchain_path, - expiry=expiry, + expiry=crypto_util.notAfter(cert_path).date(), key_msg="Key is saved at: {}\n".format(key_path) if key_path else "", - symlink_msg="These files will be automatically updated " - "every time the certificate is renewed.\n", + renew_msg="Certbot will automatically renew this certificate in the background." + if config.preconfigured_renewal else + ("These files will be updated when the certificate renews. " + f'Run "{cli.cli_constants.cli_command} renew" to renew ' + "all expiring certificates.") ) ) diff --git a/certbot/tests/main_test.py b/certbot/tests/main_test.py index 6fc762cc7..d1b4485ca 100644 --- a/certbot/tests/main_test.py +++ b/certbot/tests/main_test.py @@ -1776,8 +1776,8 @@ class ReportNewCertTest(unittest.TestCase): '\nSuccessfully received certificate.\n' 'Certificate is saved at: /path/to/fullchain.pem\n' 'Key is saved at: /path/to/privkey.pem\n' - 'These files will be automatically updated every time the certificate is renewed.\n' - 'This certificate expires on 1970-01-01.' + 'This certificate expires on 1970-01-01.\n' + 'Certbot will automatically renew this certificate in the background.\n' ) def test_report_no_key(self): @@ -1788,10 +1788,25 @@ class ReportNewCertTest(unittest.TestCase): self.mock_notify.assert_called_with( '\nSuccessfully received certificate.\n' 'Certificate is saved at: /path/to/fullchain.pem\n' - 'These files will be automatically updated every time the certificate is renewed.\n' - 'This certificate expires on 1970-01-01.' + 'This certificate expires on 1970-01-01.\n' + 'Certbot will automatically renew this certificate in the background.\n' ) + def test_report_no_preconfigured_renewal(self): + self._call(mock.Mock(dry_run=False, preconfigured_renewal=False), + '/path/to/cert.pem', '/path/to/fullchain.pem', + '/path/to/privkey.pem') + + self.mock_notify.assert_called_with( + '\nSuccessfully received certificate.\n' + 'Certificate is saved at: /path/to/fullchain.pem\n' + 'Key is saved at: /path/to/privkey.pem\n' + 'This certificate expires on 1970-01-01.\n' + 'These files will be updated when the certificate renews. ' + 'Run "certbot renew" to renew all expiring certificates.\n' + ) + + def test_csr_report(self): self._call_csr(mock.Mock(dry_run=False), '/path/to/cert.pem', '/path/to/chain.pem', '/path/to/fullchain.pem')