DISTRIBUTION: How to resolve Failed to set the PGP key during GPG keys upload

Vignesh Surendrababu
2023-01-22 11:06

JFrog Distribution uses the GPG keys pair in order to secure theRelease Bundles. The Release Bundles Distributed to Edge node is signed by the Private key and the Edge Node verifies the signature with the Public key.

When uploading the GPG Keys to the Artifactory and propagating the Keys for performing the Distribution, it is not expected to observe the error mentioned below

Error:

  1. {“detail”:“Failed setting new PGP key”,“message”:“Failed to set the PGP key”,“status_code”:400}
  2. {"detail":"Failed checking if passphrase required for key","message":"Failed to set the PGP key","status_code":400}

This indicates that there could be a possibility that the required parameters are not in the expected format on the json file used on the POST request toupload and propagate the GPG keysor the GPG Keys are not created on Linux with theexpected GPG version.

How to overcome the error?

Step 1: Make sure that the GPG keys are created using the GPG version 2.1 and higher on the Linux machines.

Step 2: Check the payload JSON file which should include the public and private keys along with other fields as below. The error may occur when the “set_as_default” parameter is not updated on the JSON file when using POST request.{
"key": {
"alias": "my-default-key",
"public_key" : "-----BEGIN PGP PUBLIC KEY BLOCK-----

-----END PGP PUBLIC KEY BLOCK-----",
"private_key": "-----BEGIN PGP PRIVATE KEY BLOCK-----

-----END PGP PRIVATE KEY BLOCK-----"
},
"propagate_to_edge_nodes" : true,
"fail_on_propagation_failure": false,
"set_as_default": true
}

Use the below REST API to upload and propagate the GPG Keys with a valid payload and GPG keyscurl -u admin:password -H "Accept: application/json" -H "Content-Type: application/json" -X POST "http://localhost:8082/distribution/api/v1/keys/gpg" -T gpg.jsonIt is expected to receive the below similar output upon successful upload and propagation is successful{"report":{"status":"SUCCESS","details":[{"jpd_id":"JPD-1","name":"HOME","key_alias":"my-default-key","status":"SUCCESS"},{"jpd_id":"JPD-2","name":"EDGE","key_alias":"my-default-key","status":"SUCCESS"}]}}