commaai/openpilot · error · RuntimeError

System time is not set; TLS certificate validation requires

Error message

System time is not set; TLS certificate validation requires a valid clock

What it means

download_profile() refuses to start when system_time_valid() is False, because TLS certificate validation against the SM-DP+ server requires a correct wall clock. Without valid time, cert expiry checks are meaningless and HTTPS would either fail or need to be insecurely disabled.

Source

Thrown at openpilot/common/esim/lpa.py:640

  return base64_trim(data[key])


def _cancel_session_safe(client: AtClient, smdp: str, tx_id: str, session: requests.Session) -> None:
  b64_cancel = ""
  try:
    b64_cancel = cancel_session(client, b64d(tx_id))
  except Exception:
    pass
  try:
    es9p_request(smdp, "cancelSession", {"transactionId": tx_id, "cancelSessionResponse": b64_cancel}, "CancelSession", session=session)
  except Exception:
    pass


def download_profile(client: AtClient, activation_code: str) -> str:
  """Download and install an eSIM profile. Returns the ICCID of the installed profile."""
  if not system_time_valid():
    raise RuntimeError("System time is not set; TLS certificate validation requires a valid clock")
  smdp, matching_id = parse_lpa_activation_code(activation_code)
  challenge, euicc_info = get_challenge_and_info(client)
  session = requests.Session()
  tx_id = None

  try:
    # step 1: initiate authentication
    auth = es9p_request(smdp, "initiateAuthentication", {
      "smdpAddress": smdp, "euiccChallenge": b64e(challenge),
      "euiccInfo1": b64e(euicc_info), "matchingId": matching_id,
    }, "Authentication", session=session)
    tx_id = _b64_field(auth, "transactionId")

    # step 2: authenticate server
    b64_auth = authenticate_server(client,
      _b64_field(auth, "serverSigned1"), _b64_field(auth, "serverSignature1"),
      _b64_field(auth, "euiccCiPKIdToBeUsed"), _b64_field(auth, "serverCertificate"),
      matching_id)

View on GitHub (pinned to 516ec1e682)

Solutions

  1. Wait for the system time source (GPS/NTP) to set the clock before calling download_profile
  2. Ensure the time-sync service runs before eSIM provisioning in startup ordering
  3. Manually set a roughly correct time if a trusted source is unavailable and re-run
Defensive patterns

Strategy: validation

Validate before calling

from openpilot.common.esim.lpa import system_time_valid

def can_download() -> bool:
    return system_time_valid()

Try / catch

try:
    download_profile(client, qr)
except RuntimeError as e:
    if "System time is not set" in str(e):
        wait_for_time_sync()
        download_profile(client, qr)

Prevention

When it happens

Trigger: Calling download_profile() on a device whose clock is unset — e.g. right after boot before GPS or NTP time sync has set the system time.

Common situations: Embedded device with no RTC battery boots before GNSS fix; time sync daemon not yet run; VM/container with unsynced clock.

Understand the failure class

Related errors


AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15). Data as JSON: /api/errors/fb6f9929cc66a9e6. Report an issue: GitHub.