0
C에서 ONVIF 인증을위한 API를 작성 중입니다. WS-UsernameToken을 만들지 만 작동하지 않습니다. 이 WS-UsernameToken에 문제가 있습니까?ONVIF 인증을위한 유효한 WS-UsernameToken을 만들고 있습니까?
unsigned int nonce_int = 0, i = 0;
time_t utcTime = 0;
struct tm *timeInfo = NULL;
char sha1_input[100] = { 0 };
SHA1Context sha = { 0 };
nonce_int = GetRandomNumber();
encode_base64(sizeof(nonce_int), (char*)&nonce_int, nonceLen, noncestr);
utcTime = time(NULL);
timeInfo = localtime(&utcTime);
strftime(timestr, timeLen, "%Y-%m-%dT%H:%M:%SZ", timeInfo);
sprintf(sha1_input, "%d%s%s", nonce_int, timestr, password);
SHA1Reset(&sha);
SHA1Input(&sha, (const unsigned char*)sha1_input, strlen(sha1_input));
if(!SHA1Result(&sha))
{
printf("\nERROR-- could not compute message digest");
}
else
{
int i = 0;
memset(sha1_input, 0x00, sizeof(sha1_input));
for(i = 0; i < 5; i++)
{
sha.Message_Digest[i] = ntohl(sha.Message_Digest[i]);
}
encode_base64(sizeof(sha.Message_Digest), (unsigned char*)sha.Message_Digest, digestLen, digeststr);
}
return 0;
그러나 이러한 값을 사용하고 ONVIF 요청을 보낼 때. 그것은 "보안 토큰을 인증 또는 인증 할 수 없습니다"라고 응답합니다. 내가 실수하고있는 곳을 궁금해했다. 고마워.