I think this is a duplicate but just to add a bit more context, you are indeed sending the incorrect digest algorithm var digest = await SHA512.HashDataAsync(stream);
for Signing ES512. RS512 is the appropriate sign algorithm for the SHA512 hashed digest.