lumeohq / onvif-rs

A native Rust ONVIF client library.
MIT License
114 stars 61 forks source link

Some camera report `NotAuthorized` with `AuthType::UsernameToken` because of `Nonce` and `Created` are too long #114

Closed asuper0 closed 9 months ago

asuper0 commented 9 months ago

The crate works well with AuthType::UsernameToken until I get a new camera, which is HikVision iDS-2DE7220MC-CSJPY. Then I tried AuthType::Digest, it could work but need request twice. I also test the camera with ONVIF Device Manager. It works well. So I compare the data by Wireshark, try to change the onvif-rs the data so it can looks like the ODM's data. I finally make it works by change Nonce and Created.

Let me show their UsernameToken field. First is the ODM one

<UsernameToken>
    <Username>
        *******
        </Username>
    <Password
        Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">
        xEIIyOTupHDXpKn9YPP+Z9wAfjs=
        </Password>
    <Nonce
        EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
        HHsjhr5rbEG8yrFaWySoEzgAAAAAAA==
        </Nonce>
    <Created
        xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        2024-02-04T07:44:17.500Z
        </Created>
    </UsernameToken>

And the onvif-rs's one.

<wsse:UsernameToken>
    <wsse:Username>
        ******
        </wsse:Username>
    <wsse:Password
        Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">
        zy9M2xmeC76ETc6d6CUBjCnuEfs=
        </wsse:Password>
    <wsse:Nonce
        EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
        NWRjODEzYjgtZTJiNi00NmEzLTgxNmItMGY5ZDI4MzlmMDE1
        </wsse:Nonce>
    <wsu:Created>
        2024-02-04T07:41:57.802907700+00:00
        </wsu:Created>
    </wsse:UsernameToken>

It's obvious that the Nonce and Created field of onvif-rs is longer than ODM.