Add-Ons & Services

How to handle a signed file

Please post support and help requests here.
Posts: 2
Joined: 07 Nov 2013, 10:53

How to handle a signed file

Postby fretboarder » 07 Nov 2013, 13:36


I don't get the clue on how to handle the following scenario with Poco:

From a remote server I want to download a particular document and another file containing the digital signature of this document.
Locally, I have the public key of the signer of the document in a certificate file.

So how would I have to implement the verification of the signature using the certificate???

Any hint would be great.


Posts: 1169
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: How to handle a signed file

Postby guenter » 07 Nov 2013, 14:42

class Poco::Crypto::RSADigestEngine may be what you're looking for. Depends on what kind of signature your server is using, though.

Posts: 2
Joined: 07 Nov 2013, 10:53

Re: How to handle a signed file

Postby fretboarder » 07 Nov 2013, 15:19

Hm, here's what I've basically tried so far:

First I created a self-signed server-certificate for my test-scenario:

Code: Select all

openssl genrsa -aes256 -out server_key.pem 1024
openssl req -new -key server_key.pem -out server.csr
openssl x509 -req -days 36500 -in server.csr -signkey server_key.pem -out server_cert.pem

Then I created an arbitraty file and a signature

Code: Select all

openssl dgst -sha256 < mysamplefile.txt > hash
openssl rsautl -sign -inkey server_key.pem -keyform PEM -in hash -out mysamplefile.txt.sig

Then I stored the certificate file server_cert.pem on my client.
Next, I download the files mysamplefile.txt and mysamplefile.txt.sig and try to verify the signature.
I read the contents of mysamplefile.txt.sig into a Digest object using a binary file input stream, and then

Code: Select all

Poco::Crypto::X509Certificate cert(<path to  server_cert.pem>);
Poco::Crypto::RSAKey pubkey(cert);
Poco::Crypto::RSADigestEngine eng(pubkey);
Poco::DigestEngine::Digest sigdigest = [ read from mysamplefile.txt.sig ]


Is that correct so far?
What has to come next?

Thank you very much!

Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest