I'm trying to verify a signature of a package on the FreeBSD package website

wget http://pkg.freebsd.org/FreeBSD:11:amd64/latest/digests.txz
tar xf digests.txz

This gives three files: digests, digests.pub digests.sig
I take it that digests.sig is a signature for the file digests with digests.pub as the public key. But I tried to confirm that:

openssl dgst -verify digests.pub -signature digests.sig digests

and got the message

Verification Failure

I assume I've got something wrong - can anyone tell me what I'm missing?

EDIT: Based on a hunt through the source code, I think the important function is to be found here , called rsa_verify_cert_cb which calls RSA_verify from the openssl library. But I haven't figured out what is being fed in to it, or whether it's possible to call that function using the openssl command line tools.


2 Answers 2


Since there is no "How To" on the Internet for manual FreeBSD package verification, here's what I have figured out.

Trick is that octet string in openssl rsautl output is in fact hash of the string that is SHA256 hash of a file.

For example, download current http://pkg.freebsd.org/FreeBSD:12:amd64/latest/digests.txz, extract it and do following:

Method 1 (one-liner using openssl dgst)

It is important here to do tr -d '\n' to drop new line from standard input, so it is not included in string input for openssl dgst.

sha256 -q digests | tr -d '\n' | openssl dgst -verify digests.pub -signature digests.sig

This command should output Verified OK.

Method 2 (visual comparison of octet string from .sig file with manualy generated hash)

  1. Use OpenSSL utility to dump contents from digests.sig

    openssl rsautl -pubin -inkey digests.pub -verify -in digests.sig -asn1parse
    0:d=0  hl=2 l=  49 cons: SEQUENCE          
    2:d=1  hl=2 l=  13 cons:  SEQUENCE          
    4:d=2  hl=2 l=   9 prim:   OBJECT            :sha256
    15:d=2  hl=2 l=   0 prim:   NULL              
    17:d=1  hl=2 l=  32 prim:  OCTET STRING      
      0000 - ac c6 ac be cd 5e 61 63-62 82 62 4b ba 77 37 6e   .....^acb.bK.w7n
      0010 - 0b fa ea ef 6e 10 21 01-62 64 06 2f d0 f1 60 22   ....n.!.bd./..`"

    Here you can see that embedded object is a SHA256 hash and its value is acc6acbecd5e61636282624bba77376e0bfaeaef6e1021016264062fd0f16022.

  2. Now calculate SHA256 of file digests:

    sha256 -q digests
  3. And finally calculate SHA256 of this string using echo command and compare with value returned by openssl rsautl:
    echo -n 8db18c93bea414fd8a281f5f3795b2ca4be51479c18b225ff87b8aa957ec2c5d | sha256

Notice how value from step 3. matches value from step 1., so file digests is valid.


That message is saying that the public key does not match the file you downloaded. According to the manpage for dgst -verify filename verify the signature using the the public key in "filename". The output is either "Verification OK" or "Verification Failure" The most likely cause is that the file got corrupted during the download. I would try to download it again and if it continues to fail the check then that's a sign of a compromised download link (but since it's from the freebsd website I'd suspect it's simply a download error. Even then I'd verify the new download just to be on the safe side). If you have a slow/unreliable internet connection it may take a few tries to get it to download right. If you ever need to check for info on commands it's always a good idea to check the manpage (man )

  • This was a while ago, but I'm pretty confident that it wasn't a download error (or a compromised download) since I tried it several times.
    – SauceCode
    Jan 27, 2018 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.