c# - Youtube PubSubHubbub hmac sha1 validation failed - Stack Overflow
3 years ago, I created a simple subscriber to the youtube pubsubhubbub api, to get notifications when a new video gets uploaded. This stopped working a few months ago, it worked until then. When I debugged what was happening, I saw that the hmac signature seems to mismatch, causing my server to not process the request.
var checksumHeader = context.Request.Headers["X-Hub-Signature"];
var signature = checksumHeader.ToString().Split('=')[1];
var stream = context.Request.Body;
string body;
using (var reader = new StreamReader(stream, Encoding.UTF8)) {
body = await reader.ReadToEndAsync();
}
var isValid = PubSubSecret.Check(body, signature);
This is my code that processes youtube's POST request. This used to work, but now isValid
always returns false
.
My Check
method:
public static bool Check(string body, string signature) {
using (var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(Secret))) {
var hashBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(body));
var hash = Convert.ToHexString(hashBytes).ToLowerInvariant();
Console.WriteLine("Sig: " + signature);
Console.WriteLine("Computed Hash " + hash);
return signature.Equals(hash);
}
}
If I use the diagnostic tool at , I can see, that youtube gets the correct secret, so this is not the problem. Also, this exact code previously worked, so I wonder what might have changed for this to stop working.
I hope someone can lead me in the right direction about what to check next.
If I copy the string body and secret to one of the many online Hmac SHA1 tools, I get the same hash as my code computes, but not what youtube sends in the header.
- 微软要逆天!SurfacePhone能运行exe程序
- Windows 10硬件产品发布会汇总 微软喊你换电脑
- 谷歌加入硬件战场:正面对抗亚马逊和苹果
- 苹果兜售没用软件脸不红心不跳
- 2012年NEC云时代平台软件全国巡展启动
- 微软反攻打响跨界战争:Win8移动领域伸橄榄枝
- Upgrading apache spark core from 3.3.2 to >=3.4.4 results in stackoverflowerror in logging - Stack Overflow
- python - How to fix autocomplete menu flickering in PyCharm on Linux? - Stack Overflow
- java - mac update sequoia 15.1 or 15.2 not work UniversalJavaApplicationStub - Stack Overflow
- python - Error with modules aiogram 3.0, how to fix? - Stack Overflow
- verilog - Is it possible to create task within interface for specific modport? - Stack Overflow
- segmentation fault - PHP-FPM sub-process dead with signal 11 when I submit a edit in MediaWiki - Stack Overflow
- javascript - Firebase Auth link - Problem with the Google login, no possibility to change to own project name - Stack Overflow
- python - Best way to chunk data from SQLAlchemy based on date? - Stack Overflow
- algorithmic trading - Why is my python script working sometimes but not others? There seems to be a delay for it to work - Stack
- VS Code : How to deactivate matching characters in bold? - Stack Overflow
- swift - Popovers not displayed inside ForEach over Enum types - Stack Overflow