def get_vcek_certificate()

in cvm-attestation/src/ImdsClient.py [0:0]


  def get_vcek_certificate(self):
    """
    Get the VCEK certificate from the IMDS endpoint.

    Returns:
      The VCEK certificate received from the IMDS endpoint.
    """

    response = self._send_request_with_retries(
      method='get',
      url=THIM_ENDPOINT,
      headers=METADATA_HEADERS,
      delay_strategy='exponential',
      exception_class=VcekCertException
    )

    try:
      data_json = response.json()
      self.log.info(f"Received VCEK certificate, TCB version: {data_json.get('tcbm')}")
      cert_chain = data_json['vcekCert'] + data_json['certificateChain']
      return bytearray(cert_chain.encode('utf-8'))
    except json.JSONDecodeError as e:
      self.log.error("Failed to decode VCEK certificate JSON", exc_info=True)
      raise VcekCertException(f"JSON decoding error: {e}") from e