The goal for Mender is to provide a robust and secure software update process. An important part of this is to give the Mender Client the ability to verify that the update comes from a trusted source. One way of achieving this is to sign the Artifact using a protected private key, which you store and use on a Signing system. The Mender Client can then verify it using the corresponding public key. If the signature verification check passes, the client considers the update to come from a trusted source and continues. Otherwise the Mender Client refuses to proceed with the update and raises an error.
The following diagram shows the high level flow of creating and managing keys and Artifact signatures. These components are essential for the Artifact signing and verification process.
The process begins with provisioning a device with the public verification key, and configuring the Mender Client to use the key (with the
ArtifactVerifyKey configuration option). After an Artifact is built, it is signed by the Signing system.
Although it is convenient and possible to use the Build system as the Signing system, this lowers the security as unauthorized access to the private signing key is made easier for potential attackers (e.g. if the Build system is compromised). The best practice is to only sign Artifacts on an offline system, ideally as a manual operation after careful inspection of the Artifact.
After you have created and signed the Artifact you can make it available to the devices running the Mender Client by uploading it to the Mender Server.
During the update installation process, the Mender Client will verify the Artifact using the corresponding public key.
The Artifact will only be installed if the verification is successful.
ArtifactVerifyKey option is set and Artifacts are not signed or the verification fails, the Mender Client will abort the update process and report an error to the Mender Server.
If the Mender Client is configured to enable signature verification (through the
ArtifactVerifyKey option), it will reject any unsigned Artifacts. This is necessary because otherwise an attacker could simply inject unsigned Artifacts to bypass the signature verification.
Mender supports the following signing algorithms:
In order to sign and later on verify the signature of the Mender Artifact we need to generate a private and public key pair. Please follow the respective section below, depending on the signature algorithm you want to use.
After generating the keys you will have a file
private.key, which you use only on the Signing system, as well as a
public.key which you provision all the devices with.
We refer to the file
artifact-verify-key.pem on the devices to avoid ambiguity with other keys.
You can generate a private RSA key by executing the command below:
openssl genpkey -algorithm RSA -out private.key -pkeyopt rsa_keygen_bits:3072 openssl rsa -in private.key -out private.key
To extract a public key from the private key use following command:
openssl rsa -in private.key -out public.key -pubout
In order to generate a public and private ECDSA key pair use the commands below:
openssl ecparam -genkey -name prime256v1 -out private-and-params.key openssl ec -in private-and-params.key -out private.key openssl ec -in private-and-params.key -pubout -out public.key
public.key files are the private and public keys, respectively.
We use the
mender-artifact tool to create a signed Artifact. Download the
mender-artifact binary for your platform following the links in
There are two ways to sign an Artifact: while creating it with the
command or for existing artifacts using the
We add the
-k parameter in both cases to specify the private key, which we will use for
creating the signature.
mender-artifact write rootfs-image \ -t beaglebone \ -n mender-master \ -f core-image-base-beaglebone.ext4 \ -k private.key \ -o artifact-signed.mender
Make sure the Artifact name specified by the
-n parameter in the above command matches the value specified when your file system image was created.
mender-artifact sign artifact.mender -k private.key -o artifact-signed.mender
The latter is typically the command that the Signing system uses to create a
signed Artifact from an unsigned one originating from the build system. Additionally, if you modify an Artifact using the
mender-artifact modify command or any other method, the signature will need to be regenerated..
After you create a signed Artifact, you can verify the signature with
mender-artifact as well, using the
-k option, but this time with the location of the public verification key.
mender-artifact validate artifact-signed.mender -k public.key
Signature verification is enabled on the Mender client using the ArtifactVerifyKey configuration option.
For OS specific instructions on how to install and enable verification keys, visit:
Found errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to submit changes.
© 2020 Northern.tech AS