24.6. Signing custom built packages
To maintain the integrity of your system, it is important to sign custom built packages before deployment. With the rpm-sign tool and IMA code signing key, you can sign your custom built packages.
Prerequisites
- You have root privileges on your system.
- You have a custom built package that you want to sign.
- You have the IMA code signing key.
-
You have the
rpm-signtool installed. - Custom IMA keys are created. See Creating custom IMA keys using OpenSSL.
Procedure
Use
rpmsign –signfilesto sign package files:# rpmsign --define "gpg_name _<GPG_KEY_NAME>" --addsign --signfiles --fskpass --fskpath=<PATH_TO_YOUR_PRIVATE_IMA_CODE_SIGNING_KEY> <PATH_TO_YOUR_RPM>--define "gpg_name _<GPG_KEY_NAME>"- The GPG key signs the package, and the IMA code signing key signs each file in the package.
--addsign- Adds the signature to the package.
--signfiles- Signs each file in the package.
--fskpass- Avoids repeatedly entering the password for the IMA code signing key.
--fskpath- Specifies the path to the IMA code signing key.
Verification
To verify that the package is signed, you can use the following command:
# rpm -q --queryformat "[%{FILENAMES} %{FILESIGNATURES}\n] <PATH_TO_YOUR_RPM>" /usr/bin/YOUR_BIN 030204... /usr/lib/YOUR_LIB.so 030204... ...