REST API to sign with client side hashing #128
-
HI Im trying to use a plainsigner to sign a file where I do the hashing clientside and I provide a digest in the REST API my worker config looks like this: my request looks like this: request url: https://signserver.local/signserver/rest/v1/workers/workerid/process the hash is calculated in python like this: at signserver Im getting this logged: signserver-ce | 2025-05-29 14:36:27,183+0000 DEBUG [org.signserver.server.data.impl.UploadConfig] (default task-3) Using default max upload field count as no HTTP_MAX_UPLOAD_FIELD_COUNT configured Reading the signserver documentation:
Ive tried supplying the hash into signserver as a base64 encoded string: myhash = sha256(file_contents.encode('utf-8')).digest() and this produces eg 1D+nI1s6NpTJtzyrNB52VR7tFH5x3XBkL4nZmFtoUhw= but its a similar invalid length error serverside. I dont think its expecting b64, but when I provide hex then its always the wrong length. A SHA-256 should be 64 bytes hex which mines is. Any ideas? Thanks, Martin |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ive got it working. For everyone's information... Here https://docs.keyfactor.com/signserver/latest/open-api-specification it defines the open api for the rest api. That worked: sending to https://signserver.local/signserver/rest/v1/workers/workerid/process It would be good to know what are the possible options for encoding. The page https://docs.keyfactor.com/signserver/latest/client-side-hashing explains about the explicit/implicit options but doesnt provide info on the rest api use case - it only examples the CLI hope this helps. thanks, martin |
Beta Was this translation helpful? Give feedback.
Ive got it working. For everyone's information...
Here https://docs.keyfactor.com/signserver/latest/open-api-specification it defines the open api for the rest api.
there is a field called encoding - the api examples NONE. Theres no info I can see what are the possible values for this field.
I tried BASE64 and calculated the hash as a b64 byte array.
That worked:
sending to https://signserver.local/signserver/rest/v1/workers/workerid/process
data: { "metaData": { "USING_CLIENTSUPPLIED_HASH" : "true", "CLIENTSIDE_HASHDIGESTALGORITHM": "SHA-256" }, "encoding": "BASE64", "data": "EAfg35LnwZfzMkHXUv3K31PlX8wqWDLhV3qsm2OFB8g=" }
<Response [200]>
archiveId : 0083bf69a48a44bb0ce6b4c2936fca82f21f…