WebSocket服务器实现(接受密钥不匹配)
C++ WebSocket Server Implementation (Accept Key missmatch)
我试着搜索,但没有找到任何答案。我正在用c++做一个websocket服务器,但是我不能让accept-key工作。
下面是我的代码:std::string magicKey = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
key.append(magicKey);
unsigned char* sha_str = SHA1(reinterpret_cast<const unsigned char*>(key.c_str()), key.length(), nullptr);
std::string final = base64_encode(reinterpret_cast<const unsigned char*>(sha_str), strlen((char*)sha_str));
我使用openssl/sha。h
您是否在末尾连接"=" ?
等效perl代码是验证是否需要
use Digest::SHA qw(sha1_base64);
my $clientKey="xyz";
my $specifcationGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
my $fullWebSocketKey = "$clientKey$specifcationGUID";
# dGhlIHNhbXBsZSBub25jZQ==258EAFA5-E914-47DA-95CA-C5AB0DC85B11
#print "Fill socket key is $fullWebSocketKeyn";
# 0xb3 0x7a 0x4f 0x2c 0xc0 0x62 0x4f 0x16 0x90 0xf6 0x46 0x06 0xcf
# 0x38 0x59 0x45 0xb2 0xbe 0xc4 0xea
print sha1_base64($fullWebSocketKey) . "=";
相关文章:
- curl_easy_perform() 失败:SSL 对等证书或 SSH 远程密钥不正常
- C++密钥和文件的映射不起作用
- Nlohmann 在不知道密钥的情况下解析 JSON 文件
- 为什么 std::map 接受 std::p air 作为密钥,而 std::unordered_map 不接受?
- 使用char*作为undered_map的密钥不会识别重复的密钥
- Xsendevent不会更改修饰符密钥状态
- 初始化静态地图,不知道密钥
- 使用数组作为地图密钥不使用C 11编译器命令
- 在不使用密钥的情况下有效地搜索哈希表
- 在不禁用其密钥的情况下注册全局热键
- SDL_GetKeyboardState 不会返回密钥的当前状态
- 向启动添加内容的代码不会生成密钥
- ECDH共享密钥在Crypto++和Android之间不匹配
- 尝试多个密钥进行 Caesar 密码解密从密钥 9 而不是 1 开始
- ssl对端证书或ssh远程密钥不正确
- 了解找不到密钥时QHash的作用
- C++:在不知道密钥的情况下插入std::map
- SecByteBlock 不接受字符串作为自定义密钥
- WebSocket服务器实现(接受密钥不匹配)
- 为什么RegOpenKeyEx允许我打开注册表编辑器中不存在的密钥?