Skip to content

repo_gpgcheck fails if key is not already imported #471

@sdherr

Description

@sdherr

Describe the bug

If your .repo file has specified repo_gpgcheck=1 to check the gpg signature of repo metadata, synchronizing the repo cache fails if the gpg key is not already imported. What it should do instead is install the gpg keys from gpgkey and try again, like gpgcheck does.

Reproduction steps

  1. mkdir /tmp/myrepo
  2. cd /tmp/myrepo
  3. wget some-rpm.rpm
  4. createrepo .
  5. cd repodata
  6. gpg --no-default-keyring --keyring isolated.keyring --full-generate-key # I chose "RSA and RSA" and defaults and "asdf" as the name.
  7. gpg --no-default-keyring --keyring isolated.keyring --armor --export asdf > repomd.xml.key
  8. gpg --no-default-keyring --keyring isolated.keyring --output repomd.xml.asc --armor --detach-sign repomd.xml
  9. cat <<EOF > /etc/yum.repos.d/myrepo.repo  
    [myrepo]  
    baseurl=file:///tmp/myrepo/  
    enabled=0   
    repo_gpgcheck=1  
    gpgkey=file:///tmp/myrepo/repodata/repomd.xml.key  
    EOF
    
  10. tdnf install -y --disablerepo=* --enablerepo myrepo some-rpm
Loaded plugin: tdnfrepogpgcheck
Refreshing metadata for: 'myrepo'
repo md signature check: No public key     659 100%
Error: TDNFVerifySignature 2004
Plugin error: repogpgcheck plugin error: failed to verify signature

Error(2004) : Unknown error 404
Error: Failed to synchronize cache for repo 'myrepo'
Error(2004) : Unknown error 404

Expected behavior

The installation should succeed. The gpgkey should be read and imported from the gpgkey option, and then checking the metadata signature should work.

Additional context

Tested on tdnf: 3.5.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions