2015-04-22 04:32:34 -04:00
|
|
|
"""Apache plugin constants."""
|
2023-09-07 14:38:44 -04:00
|
|
|
import atexit
|
|
|
|
|
import sys
|
|
|
|
|
from contextlib import ExitStack
|
2022-01-31 03:17:40 -05:00
|
|
|
from typing import Dict
|
|
|
|
|
from typing import List
|
2022-01-21 04:15:48 -05:00
|
|
|
|
2023-09-07 14:38:44 -04:00
|
|
|
if sys.version_info >= (3, 9): # pragma: no cover
|
|
|
|
|
import importlib.resources as importlib_resources
|
|
|
|
|
else: # pragma: no cover
|
|
|
|
|
import importlib_resources
|
2019-11-25 12:44:40 -05:00
|
|
|
|
2015-06-01 20:14:10 -04:00
|
|
|
MOD_SSL_CONF_DEST = "options-ssl-apache.conf"
|
2021-08-17 17:51:26 -04:00
|
|
|
"""Name of the mod_ssl config file as saved
|
|
|
|
|
in `certbot.configuration.NamespaceConfig.config_dir`."""
|
2015-04-22 04:32:34 -04:00
|
|
|
|
2017-05-23 19:25:39 -04:00
|
|
|
|
|
|
|
|
UPDATED_MOD_SSL_CONF_DIGEST = ".updated-options-ssl-apache-conf-digest.txt"
|
2021-08-17 17:51:26 -04:00
|
|
|
"""Name of the hash of the updated or informed mod_ssl_conf as saved
|
|
|
|
|
in `certbot.configuration.NamespaceConfig.config_dir`."""
|
2017-05-23 19:25:39 -04:00
|
|
|
|
2019-07-29 15:54:51 -04:00
|
|
|
# NEVER REMOVE A SINGLE HASH FROM THIS LIST UNLESS YOU KNOW EXACTLY WHAT YOU ARE DOING!
|
2022-01-21 04:15:48 -05:00
|
|
|
ALL_SSL_OPTIONS_HASHES: List[str] = [
|
2017-05-23 19:25:39 -04:00
|
|
|
'2086bca02db48daf93468332543c60ac6acdb6f0b58c7bfdf578a5d47092f82a',
|
|
|
|
|
'4844d36c9a0f587172d9fa10f4f1c9518e3bcfa1947379f155e16a70a728c21a',
|
2017-06-01 12:12:50 -04:00
|
|
|
'5a922826719981c0a234b1fbcd495f3213e49d2519e845ea0748ba513044b65b',
|
|
|
|
|
'4066b90268c03c9ba0201068eaa39abbc02acf9558bb45a788b630eb85dadf27',
|
|
|
|
|
'f175e2e7c673bd88d0aff8220735f385f916142c44aa83b09f1df88dd4767a88',
|
|
|
|
|
'cfdd7c18d2025836ea3307399f509cfb1ebf2612c87dd600a65da2a8e2f2797b',
|
2018-01-09 10:46:21 -05:00
|
|
|
'80720bd171ccdc2e6b917ded340defae66919e4624962396b992b7218a561791',
|
|
|
|
|
'c0c022ea6b8a51ecc8f1003d0a04af6c3f2bc1c3ce506b3c2dfc1f11ef931082',
|
2019-07-29 15:54:51 -04:00
|
|
|
'717b0a89f5e4c39b09a42813ac6e747cfbdeb93439499e73f4f70a1fe1473f20',
|
|
|
|
|
'0fcdc81280cd179a07ec4d29d3595068b9326b455c488de4b09f585d5dafc137',
|
|
|
|
|
'86cc09ad5415cd6d5f09a947fe2501a9344328b1e8a8b458107ea903e80baa6c',
|
|
|
|
|
'06675349e457eae856120cdebb564efe546f0b87399f2264baeb41e442c724c7',
|
2020-01-24 16:37:42 -05:00
|
|
|
'5cc003edd93fb9cd03d40c7686495f8f058f485f75b5e764b789245a386e6daf',
|
|
|
|
|
'007cd497a56a3bb8b6a2c1aeb4997789e7e38992f74e44cc5d13a625a738ac73',
|
2020-03-23 19:49:52 -04:00
|
|
|
'34783b9e2210f5c4a23bced2dfd7ec289834716673354ed7c7abf69fe30192a3',
|
2022-05-13 13:59:49 -04:00
|
|
|
'61466bc2f98a623c02be8a5ee916ead1655b0ce883bdc936692076ea499ff5ce',
|
|
|
|
|
'3fd812e3e87fe5c645d3682a511b2a06c8286f19594f28e280f17cd6af1301b5',
|
2017-05-23 19:25:39 -04:00
|
|
|
]
|
|
|
|
|
"""SHA256 hashes of the contents of previous versions of all versions of MOD_SSL_CONF_SRC"""
|
|
|
|
|
|
2023-09-07 14:38:44 -04:00
|
|
|
def _generate_augeas_lens_dir_static() -> str:
|
|
|
|
|
# This code ensures that the resource is accessible as file for the lifetime of current
|
|
|
|
|
# Python process, and will be automatically cleaned up on exit.
|
|
|
|
|
file_manager = ExitStack()
|
|
|
|
|
atexit.register(file_manager.close)
|
|
|
|
|
augeas_lens_dir_ref = importlib_resources.files("certbot_apache") / "_internal" / "augeas_lens"
|
|
|
|
|
return str(file_manager.enter_context(importlib_resources.as_file(augeas_lens_dir_ref)))
|
|
|
|
|
|
|
|
|
|
AUGEAS_LENS_DIR = _generate_augeas_lens_dir_static()
|
2015-11-04 15:12:39 -05:00
|
|
|
"""Path to the Augeas lens directory"""
|
2015-11-02 19:22:58 -05:00
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
REWRITE_HTTPS_ARGS: List[str] = [
|
2017-03-02 19:49:34 -05:00
|
|
|
"^", "https://%{SERVER_NAME}%{REQUEST_URI}", "[END,NE,R=permanent]"]
|
2015-12-01 19:16:13 -05:00
|
|
|
"""Apache version >= 2.3.9 rewrite rule arguments used for redirections to
|
2015-12-01 19:05:15 -05:00
|
|
|
https vhost"""
|
2015-11-07 23:37:57 -05:00
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
OLD_REWRITE_HTTPS_ARGS: List[List[str]] = [
|
2017-03-02 19:49:34 -05:00
|
|
|
["^", "https://%{SERVER_NAME}%{REQUEST_URI}", "[L,QSA,R=permanent]"],
|
2022-08-29 13:05:48 -04:00
|
|
|
["^", "https://%{SERVER_NAME}%{REQUEST_URI}", "[END,QSA,R=permanent]"],
|
|
|
|
|
["^", "https://%{SERVER_NAME}%{REQUEST_URI}", "[L,NE,R=permanent]"]]
|
2017-03-02 19:49:34 -05:00
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
HSTS_ARGS: List[str] = ["always", "set", "Strict-Transport-Security",
|
2016-01-14 06:25:15 -05:00
|
|
|
"\"max-age=31536000\""]
|
2015-11-06 17:31:30 -05:00
|
|
|
"""Apache header arguments for HSTS"""
|
|
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
UIR_ARGS: List[str] = ["always", "set", "Content-Security-Policy", "upgrade-insecure-requests"]
|
2015-11-07 23:37:57 -05:00
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
HEADER_ARGS: Dict[str, List[str]] = {
|
|
|
|
|
"Strict-Transport-Security": HSTS_ARGS, "Upgrade-Insecure-Requests": UIR_ARGS,
|
|
|
|
|
}
|
2018-06-21 10:27:19 -04:00
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
AUTOHSTS_STEPS: List[int] = [60, 300, 900, 3600, 21600, 43200, 86400]
|
2018-06-21 10:27:19 -04:00
|
|
|
"""AutoHSTS increase steps: 1min, 5min, 15min, 1h, 6h, 12h, 24h"""
|
|
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
AUTOHSTS_PERMANENT: int = 31536000
|
2018-06-21 10:27:19 -04:00
|
|
|
"""Value for the last max-age of HSTS"""
|
|
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
AUTOHSTS_FREQ: int = 172800
|
2018-06-21 10:27:19 -04:00
|
|
|
"""Minimum time since last increase to perform a new one: 48h"""
|
|
|
|
|
|
2022-01-21 04:15:48 -05:00
|
|
|
MANAGED_COMMENT: str = "DO NOT REMOVE - Managed by Certbot"
|
|
|
|
|
MANAGED_COMMENT_ID: str = MANAGED_COMMENT + ", VirtualHost id: {0}"
|
2018-06-21 10:27:19 -04:00
|
|
|
"""Managed by Certbot comments and the VirtualHost identification template"""
|