Skip to content

Importing Remi GPG key fails with "certificate verify failed" #425

Closed

Description

@varunvats

Using the Vagrantfile as defined here: https://github.com/geerlingguy/ansible-for-devops/blob/master/nodejs/Vagrantfile. I first encountered this error when bringing up the VM. It is reproduced below with vagrant provision:

==> default: Running provisioner: ansible...
    default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [Install EPEL repo.] ******************************************************
ok: [default]

TASK [Import Remi GPG key.] ****************************************************
fatal: [default]: FAILED! => {"changed": false, "msg": "failed to fetch key at https://rpms.remirepo.net/RPM-GPG-KEY-remi , error was: Request failed: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:618)>"}

PLAY RECAP *********************************************************************
default                    : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Activity

  1. kenhia commented on Oct 16, 2021

    @kenhia

    Same here. I can see the public key on rpms.remirepo.net in browser (no cert warnings), and both curl and wget grab it find.

    On a lark, I changed the Vagrant box to config.vm.box = "geerlingguy/centos8" and that got me post the Import Remi GPG key, so my assumption is that an updated cert root/chain exists in 8 but not in 7. Unfortunately, this now turns into an error with Install Remi repo; I don't do much node, so guessing the package needed is different.

    ...and a bit further. After some trial and error, With centos8 and changing the GPG key/Remi repo parts to:

        - name: Import Remi2018 GPG key.
          rpm_key:
            key: https://rpms.remirepo.net/RPM-GPG-KEY-remi2018
            state: present
    
        - name: Install Remi repo.
          yum:
            name: "https://rpms.remirepo.net/enterprise/remi-release-8.rpm"
            state: present

    I get to the Check list of running Node.js apps and hit a failure (possibly a typo in my version of the playbook)

    TASK [Check list of running Node.js apps.] ********************************************************************************************************************************************
    fatal: [nodejs]: FAILED! => {"changed": false, "cmd": "forever list", "msg": "[Errno 2] No such file or directory: b'forever': b'forever'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
    

    ...and I got it to work. In addition to the changes noted above, I had to tweak the the last two parts to give it a explicit path to forever.

        - name: Check list of running Node.js apps.
          command: "/usr/local/bin/forever list"
          register: forever_list
          changed_when: false
    
        - name: Start example Node.js app.
          command: "/usr/local/bin/forever start {{ node_apps_location }}/app/app.js"
          when: "forever_list.stdout.find(node_apps_location + '/app/app.js') == -1"

    My discovery phase here was to vagrant ssh into the VM, see that forever was installed and working, guess that it was a path issue (as that is what the error seemed to be). Retry and success.

    "Verified" it was working with curl http://nodejs (my dhcp seemed to drop the ".test"...problem for another day) and got "Hello, World." (Sorry, old school so the comma goes in and the bang goes to dot).

    Guessing there is a better way to set the path with Ansible, but I have neither gotten that far in Jeff's book (if it's discussed) nor searched on the Ansible site. Will probably poke around tomorrow to see if I can find the "right" way to apply the path. Did verify that the path that Ansible sees does not contain /usr/local/bin with ansible nodesvr -b -a "echo \$PATH"

  2. varunvats commented on Oct 19, 2021

    @varunvats
    Author

    Went down the same path and was able to resolve the repo related issues. Thanks for the pointer to forever's path -- that resolved the last of my remaining issues.

    forever is on the vagrant user's path, but not on sudo's path. It was installed globally, but /usr/local/bin is not configured in sudo's secure_path, so sudo cannot find it. I thought this was something that changed from CentOS 7 to CentOS 8, but I checked CentOS 7 and its sudo config also does not have /usr/local/bin in its secure_path. Wonder if this ever worked.

    [vagrant@nodejs ~]$ which forever
    /usr/local/bin/forever
    [vagrant@nodejs ~]$ sudo forever
    sudo: forever: command not found
    [vagrant@nodejs ~]$ 
    
  3. CaptainTyphoo commented on Oct 30, 2021

    @CaptainTyphoo

    The reason for the "certificate verify failed" error is that OpenSSL version 1.0.2 chooses a wrong (expired) root certificate (more details on this topic can be found here). An easy workaround is to update the packageca-certificates before importing the Remi GPG Key:

    - name: Update ca-certificates
      yum: name=ca-certificates state=latest
    

    The real fix would probably need to be done by @geerlingguy by updating the CentOS7 vagrant box.

    The issue about the not found forever command could be caused by your switch to CentOS 8, as the playbook installs forever to /bin/forever on CentOS 7.

  4. geerlingguy commented on Oct 31, 2021

    @geerlingguy
    Owner

    Marking as a bug, this example definitely needs some updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions