Fix processing LDSigned activities from actors with unknown public keys (#27474)
This commit is contained in:
		@@ -18,8 +18,8 @@ class ActivityPub::LinkedDataSignature
 | 
			
		||||
 | 
			
		||||
    return unless type == 'RsaSignature2017'
 | 
			
		||||
 | 
			
		||||
    creator   = ActivityPub::TagManager.instance.uri_to_actor(creator_uri)
 | 
			
		||||
    creator ||= ActivityPub::FetchRemoteKeyService.new.call(creator_uri, id: false)
 | 
			
		||||
    creator = ActivityPub::TagManager.instance.uri_to_actor(creator_uri)
 | 
			
		||||
    creator = ActivityPub::FetchRemoteKeyService.new.call(creator_uri, id: false) if creator&.public_key.blank?
 | 
			
		||||
 | 
			
		||||
    return if creator.nil?
 | 
			
		||||
 | 
			
		||||
@@ -28,6 +28,8 @@ class ActivityPub::LinkedDataSignature
 | 
			
		||||
    to_be_verified = options_hash + document_hash
 | 
			
		||||
 | 
			
		||||
    creator if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified)
 | 
			
		||||
  rescue OpenSSL::PKey::RSAError
 | 
			
		||||
    false
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def sign!(creator, sign_with: nil)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user