# Migration to version 4: Make usernames case-insensitive by converting to lowercase
if from_version < 4:
- self.logger.info("Converting all usernames to lowercase for case-insensitive auth")
await self.database.execute("UPDATE users SET username = LOWER(username)")
await self.database.commit()
self._certificate = get_or_create_webrtc_certificate(self.mass.storage_path)
self._remote_id = get_remote_id_from_certificate(self._certificate)
- self.logger.info("WebRTC certificate remote_id: %s", self._remote_id)
+ self.logger.debug("WebRTC certificate remote_id: %s", self._remote_id)
enabled_value = self.mass.config.get(f"{CONF_CORE}/{CONF_KEY_MAIN}/{CONF_ENABLED}", False)
self._enabled = bool(enabled_value)
# Set restrictive permissions on private key (owner read/write only)
key_path.chmod(stat.S_IRUSR | stat.S_IWUSR)
- LOGGER.info("Saved WebRTC certificate to %s", cert_path)
-
def _load_certificate(
storage_path: str,
not_after = cert.not_valid_after_utc
if now >= not_after:
- LOGGER.info("WebRTC certificate has expired")
return False
days_remaining = (not_after - now).days
- if days_remaining < CERT_RENEWAL_THRESHOLD_DAYS:
- LOGGER.info(
- "WebRTC certificate expires in %d days, will regenerate",
- days_remaining,
- )
- return False
-
- return True
+ return not days_remaining < CERT_RENEWAL_THRESHOLD_DAYS
def get_or_create_webrtc_certificate(storage_path: str) -> RTCCertificate:
if _is_certificate_valid(cert):
return RTCCertificate(key=private_key, cert=cert)
- LOGGER.info("Generating new WebRTC DTLS certificate (valid for %d days)", CERT_VALIDITY_DAYS)
+ LOGGER.debug("Generating new WebRTC DTLS certificate (valid for %d days)", CERT_VALIDITY_DAYS)
private_key, cert = _generate_certificate()
_save_certificate(storage_path, private_key, cert)