Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider 02b4d3f3 rédigé par Benjamin Neff's avatar Benjamin Neff
Parcourir les fichiers

Don't raise when the public key of a person is "broken"

Breaking a public key of a person can be used to "block" receiving posts
from this person on the pod. So we should handle that case better and
not just trigger many retries for something that will fail again.

closes #7448
parent 7d9c6c85
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -7,6 +7,7 @@
* Make photo upload button hover text translatable [#7429](https://github.com/diaspora/diaspora/pull/7429)
* Fix first comment in mobile view with french locale [#7441](https://github.com/diaspora/diaspora/pull/7441)
* Use post page title and post author in atom feed [#7420](https://github.com/diaspora/diaspora/pull/7420)
* Handle broken public keys when receiving posts [#7448](https://github.com/diaspora/diaspora/pull/7448)
## Features
......
......@@ -229,6 +229,8 @@ class Person < ActiveRecord::Base
def public_key
OpenSSL::PKey::RSA.new(serialized_public_key)
rescue OpenSSL::PKey::RSAError
nil
end
def exported_key
......
......@@ -72,8 +72,7 @@ DiasporaFederation.configure do |config|
end
on :fetch_public_key do |diaspora_id|
key = Person.find_or_fetch_by_identifier(diaspora_id).serialized_public_key
OpenSSL::PKey::RSA.new(key) unless key.nil?
Person.find_or_fetch_by_identifier(diaspora_id).public_key
end
on :fetch_related_entity do |entity_type, guid|
......
......@@ -479,6 +479,19 @@ describe Person, :type => :model do
end
end
describe "#public_key" do
it "returns the public key for the person" do
key = @person.public_key
expect(key).to be_a(OpenSSL::PKey::RSA)
expect(key.to_s).to eq(@person.serialized_public_key)
end
it "handles broken keys and returns nil" do
@person.update_attributes(serialized_public_key: "broken")
expect(@person.public_key).to be_nil
end
end
context 'people finders for webfinger' do
let(:user) { FactoryGirl.create(:user) }
let(:person) { FactoryGirl.create(:person) }
......
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