0

「usernametoken」soap リクエストを送信してデバイスの機能を取得することにより、ONVIF カメラで認証しようとしています。しかし、カメラから「要求されたアクションには承認が必要であり、送信者は承認されていません」というエラーが返されます。以下は、私が送信している「Usernametoken」です。

<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>root</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">PLAolzuaeKGkHrC7uMD52ZAvjDc=</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">DK81s1X+o0Cp0QfDg7CJ8YSeacg=</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2015-02-12T21:49:39.001Z</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"><Category>All</Category></GetCapabilities></s:Body></s:Envelope>

「ノンス」を作成する方法は次のとおりです。

string guid = Guid.NewGuid().ToString();
string nonce = GetSHA1String( guid );

public string GetSHA1String(string phrase)
{
        byte[] hashedDataBytes = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(phrase)); 
        return Convert.ToBase64String(hashedDataBytes);
}

この方法で「作成済み」を作成しています:

string created = System.DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");

この方法で PasswordDigest を作成しています。

string pwd = "admin";
string hashedPassword = CreateHashedPassword(nonce, created, pwd);

 public string CreateHashedPassword(string nonce, string created, string password)
 {
       return GetSHA1String(nonce + created + password);
 }

何が間違っているのかわかりません。この件で誰かが助けてくれることに本当に感謝しています。

4

1 に答える 1

0

ハッシュ化する場合、「ノンス + 作成済み + パスワード」のノンス部分はバイナリ データである必要があります。同様の問題については、このスレッドを参照してください: ONVIF #PasswordDigest の式は何ですか

于 2015-03-11T16:59:21.770 に答える