don't add key_id to legacy private encrypted slap xml
This commit is contained in:
parent
3811cd0c03
commit
0990eff69c
3 changed files with 13 additions and 4 deletions
|
|
@ -114,7 +114,7 @@ module DiasporaFederation
|
|||
EncryptedSlap.new.tap do |slap|
|
||||
slap.author_id = author_id
|
||||
|
||||
magic_envelope = MagicEnvelope.new(entity, author_id)
|
||||
magic_envelope = MagicEnvelope.new(entity)
|
||||
slap.cipher_params = magic_envelope.encrypt!
|
||||
slap.magic_envelope_xml = magic_envelope.envelop(privkey)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ module DiasporaFederation
|
|||
# @param [Entity] payload Entity instance
|
||||
# @param [String] sender diaspora-ID of the sender
|
||||
# @raise [ArgumentError] if either argument is not of the right type
|
||||
def initialize(payload, sender)
|
||||
raise ArgumentError unless payload.is_a?(Entity) && sender.is_a?(String)
|
||||
def initialize(payload, sender=nil)
|
||||
raise ArgumentError unless payload.is_a?(Entity)
|
||||
|
||||
@payload = payload
|
||||
@sender = sender
|
||||
|
|
@ -69,7 +69,7 @@ module DiasporaFederation
|
|||
xml["me"].data(Base64.urlsafe_encode64(payload_data), type: DATA_TYPE)
|
||||
xml["me"].encoding(ENCODING)
|
||||
xml["me"].alg(ALGORITHM)
|
||||
xml["me"].sig(Base64.urlsafe_encode64(sign(privkey)), key_id: Base64.urlsafe_encode64(sender))
|
||||
xml["me"].sig(Base64.urlsafe_encode64(sign(privkey)), key_id)
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
@ -132,6 +132,10 @@ module DiasporaFederation
|
|||
@payload_data ||= XmlPayload.pack(@payload).to_xml.strip
|
||||
end
|
||||
|
||||
def key_id
|
||||
sender ? {key_id: Base64.urlsafe_encode64(sender)} : {}
|
||||
end
|
||||
|
||||
# Builds the xml root node of the magic envelope.
|
||||
#
|
||||
# @yield [xml] Invokes the block with the
|
||||
|
|
|
|||
|
|
@ -87,6 +87,11 @@ module DiasporaFederation
|
|||
expect(doc1.xpath("d:diaspora/me:env", ns).to_xml).to eq(doc2.xpath("d:diaspora/me:env", ns).to_xml)
|
||||
end
|
||||
|
||||
it "does not add the sender to the magic envelope" do
|
||||
doc = Nokogiri::XML::Document.parse(slap_xml)
|
||||
expect(doc.at_xpath("d:diaspora/me:env/me:sig", ns)["key_id"]).to be_nil
|
||||
end
|
||||
|
||||
context "header" do
|
||||
subject {
|
||||
doc = Nokogiri::XML::Document.parse(slap_xml)
|
||||
|
|
|
|||
Loading…
Reference in a new issue