diff --git a/pywidevine/cdm.py b/pywidevine/cdm.py index 1b891a1..be14a36 100644 --- a/pywidevine/cdm.py +++ b/pywidevine/cdm.py @@ -424,7 +424,7 @@ class Cdm: @staticmethod def encrypt_client_id( client_id: ClientIdentification, - service_certificate: DrmCertificate, + service_certificate: Union[SignedMessage, SignedDrmCertificate, DrmCertificate], key: bytes = None, iv: bytes = None ) -> EncryptedClientIdentification: @@ -432,6 +432,14 @@ class Cdm: privacy_key = key or get_random_bytes(16) privacy_iv = iv or get_random_bytes(16) + if isinstance(service_certificate, SignedMessage): + signed_drm_certificate = SignedDrmCertificate() + signed_drm_certificate.ParseFromString(service_certificate.msg) + service_certificate = signed_drm_certificate + if isinstance(service_certificate, SignedDrmCertificate): + drm_certificate = DrmCertificate() + drm_certificate.ParseFromString(service_certificate.drm_certificate) + service_certificate = drm_certificate if not isinstance(service_certificate, DrmCertificate): raise ValueError(f"Expecting Service Certificate to be a DrmCertificate, not {service_certificate!r}")