RS IZ; now signatures work like in real life

This commit is contained in:
ilya 2010-07-12 20:42:22 -07:00
parent 406c00aeb6
commit b9146cbb41
4 changed files with 30 additions and 9 deletions

View file

@ -47,8 +47,11 @@ class Post
key :owner_signature, String
def verify_signature
return false unless owner_signature && person.key_fingerprint
GPGME::verify(owner_signature, {:always_trust => true}){ |signature|
puts to_xml.to_s
puts owner_signature
GPGME::verify(owner_signature, nil, {:armor => true, :always_trust => true}){ |signature|
puts signature
puts signature.inspect
return signature.status == GPGME::GPG_ERR_NO_ERROR &&
#signature.to_s.include?("Good signature from ") &&
signature.fpr == person.key_fingerprint
@ -60,7 +63,7 @@ class Post
def sign_if_mine
if self.person == User.first
self.owner_signature = GPGME::sign(to_xml.to_s,nil,{
:armor=> true, :mode => GPGME::SIG_MODE_DETACH})
:armor=> true})
end
end

14
spec/fixtures/msg.xml vendored Normal file
View file

@ -0,0 +1,14 @@
<status_message>
<message>jimmy's 1 whales</message>
<_id>4c3b7cf9312f91367f000004</_id>
<person>
<email>bob1@aol.com</email>
<url>http://www.example.com/</url>
<_id>4c3b7c64312f913664000005</_id>
<key_fingerprint>0264242496D4B585297BF236BEEFE6DEBE3407AA</key_fingerprint>
<profile>
<first_name>Bob</first_name>
<last_name>Smith</last_name>
</profile>
</person>
</status_message>

View file

@ -1,7 +1,7 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEABECAAYFAkw7p+YACgkQ5hWCpTN+yRIrHgCghpIwNtqODBwaEjL6duFNcTKv
+XYAoKWvcAz76dmAvD71QkTue5F67cq8
=jIOx
iEYEABECAAYFAkw72oUACgkQ5hWCpTN+yRLSuwCgwphc3LWMM0LOZ5wreKjNeaja
BCsAoIzYO9AG3fgV0KbtIFAtuwlNiFxt
=W2K4
-----END PGP SIGNATURE-----

View file

@ -104,7 +104,11 @@ describe 'user encryption' do
end
it 'should know if the signature is for the wrong text' do
pending
person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr)
message = Factory.create(:status_message, :message => 'I love VENISON', :person => person,
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
message.verify_signature.should be false
end
end
end