Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that GPG keys actually exist on a public keyserver #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sudo: false
addons:
apt:
packages:
- python3
python:
- "3.4"
language: python
install: "pip install gnupg"
script: ./tests.py
16 changes: 16 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
import json
import os
import sys
import gnupg

REQUIRED_FIELDS = ['publicKey', 'password', 'contact']
RECOMMENDED_FIELDS = ['gpg']
GPG_SERVERS = ["pgp.mit.edu", "keys.gnupg.net"]

RED = '\x1b[01;31m'
GREEN = '\x1b[01;32m'
YELLOW = '\x1b[01;33m'
END = '\x1b[0m'

gpg = gnupg.GPG()


def validate(path):
print("Validating %s" % path)
Expand All @@ -30,6 +34,18 @@ def validate(path):
warning = True
print(" %sHost %s is missing the recommended field %s%s" % (YELLOW, host,
field, END))
if "gpg" in peers[host]:
is_on_keyserver = False
for server in GPG_SERVERS:
gpg_result = gpg.recv_keys(server, peers[host]['gpg'])
print(" %s%s key(s) found on %s when searching for %s%s" %
(YELLOW, len(gpg_result.results), server, peers[host]['gpg'], END))
if len(gpg_result.results) > 0:
is_on_keyserver = True
if not is_on_keyserver:
print(" %s%s not found on any keyserver%s" %
(RED, peers[host]['gpg'], END))
return False
if warning:
print(" %sSuccess, but missing recommended fields%s" % (YELLOW, END))
else:
Expand Down