Skip to content

Commit 8527887

Browse files
committed
fix: One more check
1 parent f7a2150 commit 8527887

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/c2pa/c2pa.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ def __init__(self, alg=None, sign_cert=None, private_key=None, ta_url=None):
245245
else:
246246
alg = None
247247

248+
# Handle ta_url parameter - convert string to bytes if needed
249+
if ta_url is not None:
250+
if isinstance(ta_url, str):
251+
# Convert string to bytes
252+
ta_url = ta_url.encode('utf-8')
253+
elif isinstance(ta_url, bytes):
254+
# Already in bytes format
255+
pass
256+
else:
257+
raise TypeError(f"ta_url must be string or bytes, got {type(ta_url)}")
258+
248259
# Call parent constructor with processed values
249260
super().__init__(alg, sign_cert, private_key, ta_url)
250261

tests/test_unit_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ def test_sign_file_alg_as_enum(self):
14091409
alg=SigningAlg.ES256,
14101410
sign_cert=certs,
14111411
private_key=key,
1412-
ta_url=b"http://timestamp.digicert.com"
1412+
ta_url="http://timestamp.digicert.com"
14131413
)
14141414

14151415
# Create a simple manifest

0 commit comments

Comments
 (0)