Getting a public key for signature verification
Use a GPG public key to verify the signature of signed images in a Continuous Deployment (CD) pipeline.
You can get a GPG public key as follows:
- Using the continuous integration (CI) pipeline.
- Using your local computer.
Getting a GPG public key by using the continuous integration (CI) pipeline
-
To get a public key, add the environment variable
print-code-signing-certificate
with a value of 1 in your CI pipeline. After you run the CI pipeline, the GPG public key is printed on the console in thebuild-sign-artifact
stage. You can then copy the public key into a file and encode it in base64 format by running the following command:cat copied_key.txt | base64
-
Copy the encoded key into your continuous deployment (CD) pipeline.
Getting a GPG public key by using your local computer
If you have the GPG private key in your key ring, you can export the public key directly.
-
Check whether your machine has a GPG key ring. Key rings are groupings of keys that allow those groupings to be managed independently. For more information, see Grouping keys together using key rings. Run the following command:
gpg --list-keys /home/user/.gnupg/pubring.kbx ------------------------------- pub rsa3072 2021-04-15 [SC] [expires: 2023-04-15] 88DC11E8FDDF028F02E4184719D6C4C5990F144F uid [ unknown] user name <user.name@email.com> sub rsa3072 2021-04-15 [E] [expires: 2023-04-15]
-
If the GPG key exists on your computer, export the GPG public key by running the following command:
gpg --armor --export <Email Address> -----BEGIN PGP PUBLIC KEY BLOCK----- xsBNBGQICw0BCADS5GwuET5rkH6n1e6bM8sYod5Apbf06yQqhAFz5hkAWCu50Nw0 GEyxRQCAxp+9xERSr43W0StSaL9KGHBaB3oS9evkcIrlOkTwncvAZODAsaorcRtW 1IkICPhztRHyN+wR2TWadatHz/RvOlEDVAg51XLfFIQibTStgweB3rV2c5jTsCUc C6N6sNoHx4OhLZ7BNJSSZBByyt4qf3d2yErOULjjUCYsvcTaOM4gtXx4Cbsk7F/y kZnCCqFimPOJKjsXjc+6hyAKgG0xRIGtv/zzU+nwew2fDblWTwZjDx4V9KZl1o07 XBHfNu0hKgvQhJURxY7gCtYtIHoDF5xI2/OfABEBAAHNGmV0c3QgPHVzZXIubmFt ZUBlbWFpbC5jb20+wsBtBBMBCgAXBQJkCAsNAhsvAwsJBwMVCggCHgECF4AACgkQ 8aKO5nwRdmhECwf9Fl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b4xuFd9dqNC9wJ2aGDXcGFnDvAoq YSZZl5KWY/11AqBR9smeMyZrK8SAAw8dFPpVNsLWGdTKrywfSjcBUqasoI2QvFJB Nbmu7JILvEsMXtA2vjJ3SQtOVZs744mo9fi8Jpu/V7P7v+88u8EYWwf+OgQUJT/e WzslyV2/ST9+ozxfsGwpl9hlzmPQ4B+a7wNPTqRwCrJgaVIz3Q3LzV06wv7b0YmU Vz1j3Zv2SrQntYGR6F4Whi/j4vLl19eI0LhnxcOw4/Ry4pQ8NnypF63Vz7XpNEaf vF/P82FwXHR0OvOhEt3UgGdxvC69VF8tHlqaXjMLvmoBMrk1oi2ZDONo/3v9xwzO EnxlN5I7ah3n9aBt+D0NZ8EU2qfclMNEEI4viGzB++BEUMbflmbnFdt2Nmbqk1pe bknJV8p6m/r56kBPDvk5uqd/L2+j50MrAu4RFNIy4qx+ub1MxqU+MZGjFa3O46Al ftfswLBW+es4fQ== =0FYC -----END PGP PUBLIC KEY BLOCK-----
-
After you export the GPG public key, encode it in
base64
format before you copy it to thecode-signing-certificate
field.
Store the key
Provide the GPG key to the CD pipeline in one of the following ways:
- Store the key in IBM® Key Protect for IBM Cloud®.
- Store the key in IBM Cloud® Secrets Manager.
- Store the key directly in the CI toolchain.
Make sure that the key is copied in the correct format to prevent a CI pipeline signing error. Use pbcopy
(OS X) or clip
(Windows Git bash) in the commands specified in the following sections to copy the key content
to the clipboard.
Store the key in Key Protect
You must double base64
encode the GPG key before you store it in your Key Protect instance.
Export and copy the GPG key to the clipboard as follows:
-
OS X
gpg --armor --export <Email Address> | base64 | base64 | pbcopy
-
Windows
gpg --armor --export <Email Address> | base64 -w0 | base64 -w0 | clip
-
Linux
gpg --armor --export <Email Address> | base64 | base64
-
In your IBM Cloud console, select the Key Protect instance where you want to store the GPG key that you generated.
-
Click the Add icon to add new key to the instance.
-
Select Import your own key option.
-
Select key type as Standard Key.
-
Give an appropriate name in the Key name field. The stored GPG key can be retrieved later by using this name.
-
Copy the key that you exported in the Key material field.
Ensure that there is no extra line at the end of the key when you copy the key and paste it in the Key material field.
-
Expand the Advanced Options section and select the Choose a key ring option as default.
-
Add the key to your key protect by clicking Add key.
For more information on Key Protect, see About Key Protect.
Store the key in Secrets Manager
You must single base64
encode the GPG key before you store it in your Secrets Manager instance.
-
Export and copy the GPG key to the clipboard.
-
OS X
gpg --armor --export <Email Address> | base64 | pbcopy
-
Windows
gpg --armor --export <Email Address> | base64 -w0 | clip
-
Linux
gpg --armor --export <Email Address> | base64
-
-
In your IBM Cloud console, select the Secrets Manager instance where you want to store the GPG Key that you generated in the previous steps.
-
Click the Add icon to add new key to the instance.
-
Select the Other secret type option.
-
Select key type as Standard Key.
-
Give an appropriate name in the Name field. The stored GPG key can be retrieved later by using this name.
-
Choose the option as Secret value and paste the key as exported earlier in the Secret value field.
Ensure that there is no extra line at the end of the key when you copy the key and paste it in Secret value field.
-
Add the key to your Key Protect instance by clicking Add.
For more information on Secrets Manager, see Getting started with Secrets Manager.
Export the private key and store it directly in the CI pipeline
Use this method for testing only. Use keyprotect
or secrets manager
for storing keys.
You must single base64
encode the GPG key before storing it as a secured pipeline property.
Securely store the GPG key in a Key Protect or Secrets Manager instance as follows:
-
OS X or Linux
gpg --armor --export <Email Address> | base64
-
Windows
gpg --armor --export <Email Address> | base64 -w0