To secure your code, use OpenSSL to generate a Certificate Signing Request (CSR) for your digital certificates.
Before you begin
- The custom IMA CA key has the following extensions:
- The basic constraints extension with the CA boolean asserted.
- The
KeyUsage extension with the keyCertSign bit asserted but without the digitalSignature asserted.
- The custom IMA code signing key falls under the following criteria:
- The IMA CA key signed this custom IMA code signing key.
- The custom key includes the
subjectKeyIdentifier extension.
- UEFI Secure Boot on
x86_64 or aarch64 systems or PowerVM Secure Boot on ppc64le systems is enabled.
About this task
The kernel searches the .ima keyring for a code signing key to verify an Integrity Measurement Architecture (IMA) signature. Before you add a code signing key to the .ima keyring, you need to ensure that IMA CA key signed this key in the .builtin_trusted_keys or .secondary_trusted_keys keyrings.
Procedure
-
To generate a custom IMA CA key pair, run:
# openssl req -new -x509 -utf8 -sha256 -days 3650 -batch -config ima_ca.conf -outform DER -out custom_ima_ca.der -keyout custom_ima_ca.priv
-
Optional: To check the content of the
ima_ca.conf file, run:
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = ca
[ req_distinguished_name ]
O = YOUR_ORG
CN = YOUR_COMMON_NAME IMA CA
emailAddress = YOUR_EMAIL
[ ca ]
basicConstraints=critical,CA:TRUE
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
keyUsage=critical,keyCertSign,cRLSign
-
To generate a private key and a certificate signing request (CSR) for the IMA code signing key, run:
# openssl req -new -utf8 -sha256 -days 365 -batch -config ima.conf -out custom_ima.csr -keyout custom_ima.priv
-
Optional: To check the content of the
ima.conf file, run:
[ req ]
default_bits = 2048
distinguished_name = req_distinguished_name
prompt = no
string_mask = utf8only
x509_extensions = code_signing
[ req_distinguished_name ]
O = YOUR_ORG
CN = YOUR_COMMON_NAME IMA signing key
emailAddress = YOUR_EMAIL
[ code_signing ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
-
Use the IMA CA private key to sign the CSR to create the IMA code signing certificate:
# openssl x509 -req -in custom_ima.csr -days 365 -extfile ima.conf -extensions code_signing -CA custom_ima_ca.der -CAkey custom_ima_ca.priv -CAcreateserial -outform DER -out ima.der