LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2014, 09:35 PM   #1
0x53h
LQ Newbie
 
Registered: May 2012
Posts: 23

Rep: Reputation: Disabled
Python - Obtain GPG key id from detatched signature file


Before I try parsing the key id from stdout I thought I'd ask if anyone has a better suggestion. The python-gnupg does verification, but only if the public key is already imported into a keyring.

My goal is to automate source integrity verification. Given a download url, I can probably guess the signature file (if one exists). Given a signature file I should be able to get the key id and obtain the public key of the signee. Then complete the verification process. Better ideas or welcome, or a polite "you're crazy" works too.

Example below is how it already works well on the command line. I'd like to do this in Python.

Code:
user@boxen:~/$ gpg --verify ./rsync-3.1.1.tar.gz.asc 
gpg: Signature made Sun 22 Jun 2014 01:13:20 PM EDT using DSA key ID 4B96A8C5
gpg: Can't check signature: public key not found

user@boxen:~/$ gpg --recv-keys 4B96A8C5
gpg: requesting key 4B96A8C5 from hkp server keys.gnupg.net
gpg: key 4B96A8C5: public key "Wayne Davison <wayned@example.com>" imported
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: Total number processed: 1
gpg:               imported: 1

user@boxen:~/$ gpg --verify ./rsync-3.1.1.tar.gz.asc 
gpg: Signature made Sun 22 Jun 2014 01:13:20 PM EDT using DSA key ID 4B96A8C5
gpg: Good signature from "Wayne Davison <wayned@example.com>"
gpg:                 aka "Wayne Davison <wayned@example.net>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 0048 C8B0 26D4 C96F 0E58  9C2F 6C85 9FB1 4B96 A8C5

Last edited by 0x53h; 10-21-2014 at 09:36 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] gpg - Can't check signature: public key not found when decrypting file ilesterg Linux - Security 3 02-12-2014 09:52 AM
[SOLVED] How can I decrypt GPG file that encrypted with my lost private key ? mesuutt Linux - General 4 12-17-2011 11:07 AM
GPG: Bad session key gpg between gpg on linux and gpg gui on windows XP konqi Linux - Software 1 07-21-2009 09:37 AM
How to modify a GPG signed file while preserving the signature? colucix Linux - Security 4 07-21-2008 03:34 AM
Sign a JAR file with a GPG key? Wynd Programming 1 12-02-2007 08:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration