diff --git a/homeassistant/components/mqtt/config_flow.py b/homeassistant/components/mqtt/config_flow.py index 5d8b19ce31a..5e5beb2f314 100644 --- a/homeassistant/components/mqtt/config_flow.py +++ b/homeassistant/components/mqtt/config_flow.py @@ -482,8 +482,8 @@ async def async_get_broker_settings( return False certificate_id: str | None = user_input.get(CONF_CERTIFICATE) if certificate_id: - with process_uploaded_file(hass, certificate_id) as certiticate_file: - certificate = certiticate_file.read_text(encoding=DEFAULT_ENCODING) + with process_uploaded_file(hass, certificate_id) as certificate_file: + certificate = certificate_file.read_text(encoding=DEFAULT_ENCODING) # Return to form for file upload CA cert or client cert and key if ( @@ -499,8 +499,8 @@ async def async_get_broker_settings( if client_certificate_id: with process_uploaded_file( hass, client_certificate_id - ) as client_certiticate_file: - client_certificate = client_certiticate_file.read_text( + ) as client_certificate_file: + client_certificate = client_certificate_file.read_text( encoding=DEFAULT_ENCODING ) if client_key_id: @@ -704,10 +704,10 @@ def try_connection( def check_certicate_chain() -> str | None: """Check the MQTT certificates.""" - if client_certiticate := get_file_path(CONF_CLIENT_CERT): + if client_certificate := get_file_path(CONF_CLIENT_CERT): try: - with open(client_certiticate, "rb") as client_certiticate_file: - load_pem_x509_certificate(client_certiticate_file.read()) + with open(client_certificate, "rb") as client_certificate_file: + load_pem_x509_certificate(client_certificate_file.read()) except ValueError: return "bad_client_cert" # Check we can serialize the private key file @@ -719,9 +719,9 @@ def check_certicate_chain() -> str | None: return "bad_client_key" # Check the certificate chain context = SSLContext(PROTOCOL_TLS) - if client_certiticate and private_key: + if client_certificate and private_key: try: - context.load_cert_chain(client_certiticate, private_key) + context.load_cert_chain(client_certificate, private_key) except SSLError: return "bad_client_cert_key" # try to load the custom CA file diff --git a/homeassistant/components/mqtt/strings.json b/homeassistant/components/mqtt/strings.json index 8d3a4ad3445..5788597e9a9 100644 --- a/homeassistant/components/mqtt/strings.json +++ b/homeassistant/components/mqtt/strings.json @@ -47,7 +47,7 @@ "bad_will": "Invalid will topic", "bad_discovery_prefix": "Invalid discovery prefix", "bad_certificate": "The CA certificate is invalid", - "bad_client_cert": "Invalid client certiticate, ensure a PEM coded file is supplied", + "bad_client_cert": "Invalid client certificate, ensure a PEM coded file is supplied", "bad_client_key": "Invalid private key, ensure a PEM coded file is supplied without password", "bad_client_cert_key": "Client certificate and private are no valid pair", "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", diff --git a/homeassistant/components/mqtt/translations/en.json b/homeassistant/components/mqtt/translations/en.json index 74ecf3ccb11..00078b1082a 100644 --- a/homeassistant/components/mqtt/translations/en.json +++ b/homeassistant/components/mqtt/translations/en.json @@ -7,7 +7,7 @@ "error": { "bad_birth": "Invalid birth topic", "bad_certificate": "The CA certificate is invalid", - "bad_client_cert": "Invalid client certiticate, ensure a PEM coded file is supplied", + "bad_client_cert": "Invalid client certificate, ensure a PEM coded file is supplied", "bad_client_cert_key": "Client certificate and private are no valid pair", "bad_client_key": "Invalid private key, ensure a PEM coded file is supplied without password", "bad_discovery_prefix": "Invalid discovery prefix", @@ -81,7 +81,7 @@ "error": { "bad_birth": "Invalid birth topic", "bad_certificate": "The CA certificate is invalid", - "bad_client_cert": "Invalid client certiticate, ensure a PEM coded file is supplied", + "bad_client_cert": "Invalid client certificate, ensure a PEM coded file is supplied", "bad_client_cert_key": "Client certificate and private are no valid pair", "bad_client_key": "Invalid private key, ensure a PEM coded file is supplied without password", "bad_discovery_prefix": "Invalid discovery prefix", @@ -130,4 +130,4 @@ } } } -} \ No newline at end of file +} diff --git a/homeassistant/components/mqtt/util.py b/homeassistant/components/mqtt/util.py index ab907854499..bfd961871d3 100644 --- a/homeassistant/components/mqtt/util.py +++ b/homeassistant/components/mqtt/util.py @@ -191,7 +191,7 @@ def migrate_certificate_file_to_content(file_name_or_auto: str) -> str | None: if file_name_or_auto == "auto": return "auto" try: - with open(file_name_or_auto, encoding=DEFAULT_ENCODING) as certiticate_file: - return certiticate_file.read() + with open(file_name_or_auto, encoding=DEFAULT_ENCODING) as certificate_file: + return certificate_file.read() except OSError: return None