鉴权过程如下:
客户端第一次请求 onvif 设备,如 onvif 设备验证 Authorization 失败,则响应 401,同时响应头包含 WWW-Authenticate
头信息(onvif 设备生成的随机数),客户端拿到该数据后根据下面公式计算 digest,再次请求,同时携带计算的 digest 数据即可成功请求。
客户端第一次请求
POST /onvif/PTZ HTTP/1.1
Host: 192.168.1.212
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 644
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><AbsoluteMove xmlns="http://www.onvif.org/ver20/ptz/wsdl"><ProfileToken>media_profile_token1</ProfileToken><Position><PanTilt x="0.01" y="0.01" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/PositionGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/><Zoom x="0" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace" xmlns="http://www.onvif.org/ver10/schema"/></Position></AbsoluteMove></s:Body></s:Envelope>HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm="IPC_CAM", qop="auth,auth-int", nonce="62fb10dacb7f08aa31fc", opaque="025f3a12"
Server: gSOAP/2.8
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1707
Connection: close
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/