You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Introduction

This document describes how to check the signature of a file signed with an X.509 certificate from the command line using OpenSSL.

The examples uses EC private keys only.

Extracting the Public Key from the X.509 Certificate

To check a signature with OpenSSL we use the public key related to the private key the file was signed with. We extract the public key to the pubkey.pem file from the given certificate.pem X.509 certificate file.

openssl x509 -in certificate.pem -noout -pubkey > pubkey.pem

Signing a File with a Private Key

In this step a file test.txt is signed with the privkey.pem private key file, the binary signature is stored to the test.txt.sig file.

openssl dgst -sign privkey.pem -keyform pem -sha256 -out test.txt.sig -binary test.txt

Checking the Signature by use of the Public Key

In this step the pubkey.pem public key file is used to check if the test.txt.sig signature file matches the test.txt file.

openssl dgst -verify pubkey.pem -keyform pem -sha256 -signature test.txt.sig -binary test.txt

Possible results are 

  • Verified OK
    • The public key and signature for the signed file match.
  • Verification Failure
    • The public key and signature do not match.



  • No labels