Skip to content
Extraits de code Groupes Projets
Valider b9146cbb rédigé par ilya's avatar ilya
Parcourir les fichiers

RS IZ; now signatures work like in real life

parent 406c00ae
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
<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>
\ No newline at end of file
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
iEYEABECAAYFAkw7p+YACgkQ5hWCpTN+yRIrHgCghpIwNtqODBwaEjL6duFNcTKv
+XYAoKWvcAz76dmAvD71QkTue5F67cq8
=jIOx
iEYEABECAAYFAkw72oUACgkQ5hWCpTN+yRLSuwCgwphc3LWMM0LOZ5wreKjNeaja
BCsAoIzYO9AG3fgV0KbtIFAtuwlNiFxt
=W2K4
-----END PGP SIGNATURE-----
......@@ -85,7 +85,7 @@ describe 'user encryption' do
it 'should verify a remote signature' do
person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr)
message = Factory.create(:status_message, :person => person,
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read)
......@@ -95,7 +95,7 @@ describe 'user encryption' do
it 'should know if the signature is from the wrong person' do
person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr)
message = Factory.create(:status_message, :person => person,
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
:owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read)
# :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read)
......@@ -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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter