Introduction
Problem
Initializing Terraform code with a private provider from the Terraform Enterprise (TFE) Private Registry throws the following error
│ Error: Failed to install provider
│
│ Error while installing terraform.instance-test.com/test-org/oci v5.29.0: authentication signature from unknown issuer
Prerequisites
- The provider should be in the Private Registry of TFE
Cause
- The signature file of the provider has been signed with a different GPG key than the GPG key that has been uploaded to the private registry of TFE.
- This can happen when you have multiple GPG keys on your computer/VM
- To check the list of your GPG keys you can use the following command:
#list gpg keys
$ gpg -k
-
- See the output below:
[keyboxd]
---------
pub rsa3072 2024-02-20 [SC]
558E414E5FF6F144027905D4EB71BE6B68B95EDB
uid [ultimate] daniela (daniela-key) <name@gmail.com>
sub rsa3072 2024-02-20 [E]
pub rsa3072 2024-02-23 [SC]
83D111902A5D5051C8AC37C11472E022D7760B02
uid [ultimate] test-key (testing-key) <test@key.com>
sub rsa3072 2024-02-23 [E]
-
- To verify which key is currently used and uploaded to your TFE Private Registry, you can use this API from here
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request GET \
"https://daniela.hashicorpdemo.com/api/registry/private/v2/gpg-keys?filter%5Bnamespace%5D=daniela-org" | jq '.'
-
- See in the JSON response below, the value of the key-id = 1472E022D7760B02
{
"data": [
{
"type": "gpg-keys",
"id": "4",
"attributes": {
"ascii-armor": "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\nmQGNBGXYYVsBDACmgAKY8nKsYQK9MKVcteLgTD2o1wfjRSqZEupoQTYRmSgMKu5G\nO8pnHcKeqtoj7Nplc+it07iUJVyGOgTH1PWEXFY70MvjXdThQA6rf+3XyWRztO/B\nyaFRDn3g3kWWEUm4HTTL+AKOTRmL21Yp4SnBcj+1J3eg3/hZHbwlZawh7a4VSRYW\ntMf+vmcl0RGY0L9Br/m4wUoeRHr6HW3OIzCQhb5ZKPOuB/igyGZTeVFcQCWGk3pb\nC1gtzznlTZ908MdY0jlb7RRcv9njjIsWFB+PHcIEqJ/xnVnmBDp+LLuCbMdqTj5u\nsDVG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key-id": "1472E022D7760B02",
"namespace": "daniela-org",
"source": "",
"source-url": null,
"trust-signature": "",
"updated-at": "2024-02-23T09:59:36Z"
},
"links": {
"self": "/v2/gpg-keys/4"
}
}
],
"links": {
"first": "/v2/gpg-keys?filter%5Bnamespace%5D=daniela-org&page%5Bnumber%5D=1&page%5Bsize%5D=15",
"last": "/v2/gpg-keys?filter%5Bnamespace%5D=daniela-org&page%5Bnumber%5D=1&page%5Bsize%5D=15",
"next": null,
"prev": null
},
"meta": {
"pagination": {
"page-size": 15,
"current-page": 1,
"next-page": null,
"prev-page": null,
"total-pages": 1,
"total-count": 1
}
}
}
-
- The value of the key-id previously retrieved 1472E022D7760B02 is matching the last 16 characters of the second key from this example, therefore this is the key that has been uploaded and is used in Terraform Enterprise in the Private Registry for your private provider:
pub rsa3072 2024-02-23 [SC]
83D111902A5D5051C8AC37C11472E022D7760B02
uid [ultimate] test-key (testing-key) <test@key.com>
sub rsa3072 2024-02-23 [E]
Solutions:
-
Append the correct GPG key and sign the provider's files again with the updated GPG key:
gpg --default-key <gpg-key-id> --detach-sign terraform-provider-oci_5.29.0_SHA256SUMS
- Upload again the newly generated SHA256SUMS.sig file to your Private Registry and redo all the steps that involve the signature file from the official documentation.
Outcome
Issue should be fixed and Terraform should be able to initialize the private provider successfully.