我正在尝试制作一个机器人来访问并使用BitStamp API(https://www.bitstamp.net/api/),但我遇到了麻烦。
在链接的页面中,他们展示了如何使用c++(V2版本)进行身份验证的示例。我在使用openSSL进行身份验证时遇到了问题:
使用openSSL 3.0,HMAC_CTX似乎已被弃用。编译时出现以下错误消息:
错误C4996'HMAC_Update':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 70
错误C4996'HMAC_Init_ex':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 69
错误C4996'HMAC_Final':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 71
错误C4996'HMAC_CTX_reset':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 72
错误C4996'HMAC_CTX_new':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 68
我已经在互联网上搜寻过任何迁移提示,但是找不到任何资料。请问有哪位好心的人能帮帮我或指导我如何将此代码迁移到支持openSSL3.0的代码?
在链接的页面中,他们展示了如何使用c++(V2版本)进行身份验证的示例。我在使用openSSL进行身份验证时遇到了问题:
HMAC_CTX ctx;
HMAC_CTX_init(&ctx);
HMAC_Init_ex(&ctx, api_secret.c_str(), api_secret.length(), EVP_sha256(), NULL);
HMAC_Update(&ctx, (unsigned char*)data_to_sign.c_str(), data_to_sign.length());
HMAC_Final(&ctx, result, &len);
HMAC_CTX_cleanup(&ctx);
std::string x_auth_signature = b2a_hex( (char *)result, 32 );
free(result);
并且
std::string b2a_hex(char *byte_arr, int n)
{
const static std::string hex_codes = "0123456789abcdef";
std::string hex_string;
for ( int i = 0; i < n ; ++i ) {
unsigned char bin_value = byte_arr[i];
hex_string += hex_codes[( bin_value >> 4 ) & 0x0F];
hex_string += hex_codes[bin_value & 0x0F];
}
return hex_string;
}
使用openSSL 3.0,HMAC_CTX似乎已被弃用。编译时出现以下错误消息:
错误C4996'HMAC_Update':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 70
错误C4996'HMAC_Init_ex':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 69
错误C4996'HMAC_Final':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 71
错误C4996'HMAC_CTX_reset':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 72
错误C4996'HMAC_CTX_new':自OpenSSL 3.0以来 StonksBot C:\ CodeProjects \ StonksBot \ StonksBot \ Source \ StonksBot \ Requests \ AuthenticationRequest.cpp 68
我已经在互联网上搜寻过任何迁移提示,但是找不到任何资料。请问有哪位好心的人能帮帮我或指导我如何将此代码迁移到支持openSSL3.0的代码?