Fix mqtt typo (#82086)

mqtt: fix "certiticate" typo
This commit is contained in:
Aarni Koskela
2022-11-14 17:22:23 +02:00
committed by GitHub
parent 7d5794cfb1
commit bbda122c99
4 changed files with 15 additions and 15 deletions

View File

@@ -482,8 +482,8 @@ async def async_get_broker_settings(
return False return False
certificate_id: str | None = user_input.get(CONF_CERTIFICATE) certificate_id: str | None = user_input.get(CONF_CERTIFICATE)
if certificate_id: if certificate_id:
with process_uploaded_file(hass, certificate_id) as certiticate_file: with process_uploaded_file(hass, certificate_id) as certificate_file:
certificate = certiticate_file.read_text(encoding=DEFAULT_ENCODING) certificate = certificate_file.read_text(encoding=DEFAULT_ENCODING)
# Return to form for file upload CA cert or client cert and key # Return to form for file upload CA cert or client cert and key
if ( if (
@@ -499,8 +499,8 @@ async def async_get_broker_settings(
if client_certificate_id: if client_certificate_id:
with process_uploaded_file( with process_uploaded_file(
hass, client_certificate_id hass, client_certificate_id
) as client_certiticate_file: ) as client_certificate_file:
client_certificate = client_certiticate_file.read_text( client_certificate = client_certificate_file.read_text(
encoding=DEFAULT_ENCODING encoding=DEFAULT_ENCODING
) )
if client_key_id: if client_key_id:
@@ -704,10 +704,10 @@ def try_connection(
def check_certicate_chain() -> str | None: def check_certicate_chain() -> str | None:
"""Check the MQTT certificates.""" """Check the MQTT certificates."""
if client_certiticate := get_file_path(CONF_CLIENT_CERT): if client_certificate := get_file_path(CONF_CLIENT_CERT):
try: try:
with open(client_certiticate, "rb") as client_certiticate_file: with open(client_certificate, "rb") as client_certificate_file:
load_pem_x509_certificate(client_certiticate_file.read()) load_pem_x509_certificate(client_certificate_file.read())
except ValueError: except ValueError:
return "bad_client_cert" return "bad_client_cert"
# Check we can serialize the private key file # Check we can serialize the private key file
@@ -719,9 +719,9 @@ def check_certicate_chain() -> str | None:
return "bad_client_key" return "bad_client_key"
# Check the certificate chain # Check the certificate chain
context = SSLContext(PROTOCOL_TLS) context = SSLContext(PROTOCOL_TLS)
if client_certiticate and private_key: if client_certificate and private_key:
try: try:
context.load_cert_chain(client_certiticate, private_key) context.load_cert_chain(client_certificate, private_key)
except SSLError: except SSLError:
return "bad_client_cert_key" return "bad_client_cert_key"
# try to load the custom CA file # try to load the custom CA file

View File

@@ -47,7 +47,7 @@
"bad_will": "Invalid will topic", "bad_will": "Invalid will topic",
"bad_discovery_prefix": "Invalid discovery prefix", "bad_discovery_prefix": "Invalid discovery prefix",
"bad_certificate": "The CA certificate is invalid", "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_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", "bad_client_cert_key": "Client certificate and private are no valid pair",
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",

View File

@@ -7,7 +7,7 @@
"error": { "error": {
"bad_birth": "Invalid birth topic", "bad_birth": "Invalid birth topic",
"bad_certificate": "The CA certificate is invalid", "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_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_client_key": "Invalid private key, ensure a PEM coded file is supplied without password",
"bad_discovery_prefix": "Invalid discovery prefix", "bad_discovery_prefix": "Invalid discovery prefix",
@@ -81,7 +81,7 @@
"error": { "error": {
"bad_birth": "Invalid birth topic", "bad_birth": "Invalid birth topic",
"bad_certificate": "The CA certificate is invalid", "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_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_client_key": "Invalid private key, ensure a PEM coded file is supplied without password",
"bad_discovery_prefix": "Invalid discovery prefix", "bad_discovery_prefix": "Invalid discovery prefix",
@@ -130,4 +130,4 @@
} }
} }
} }
} }

View File

@@ -191,7 +191,7 @@ def migrate_certificate_file_to_content(file_name_or_auto: str) -> str | None:
if file_name_or_auto == "auto": if file_name_or_auto == "auto":
return "auto" return "auto"
try: try:
with open(file_name_or_auto, encoding=DEFAULT_ENCODING) as certiticate_file: with open(file_name_or_auto, encoding=DEFAULT_ENCODING) as certificate_file:
return certiticate_file.read() return certificate_file.read()
except OSError: except OSError:
return None return None