我需要向流媒体服务器验证我的 RTSP 流,这是挑战:
RTSP/1.0 401 Unauthorized
WWW-Authenticate: Digest realm="Streaming Server", nonce="76bfe6986d3e766424de9bd6e7d3ccc1"
Session: 1845562184;timeout=60
Cseq: 1
...
Wirecast 设法使用这些设置成功进行身份验证:
Host name : 192.168.33.9:1935/live/my_stream.sdp
location : live/my_stream.sdp
username : user
password : test
它的响应是:e1dff363b9763df0c7615429af79715c
所以根据wikipedia我尝试使用以下方法进行身份验证:
//H(data) = MD5(data)
//KD(secret, data) = H(secret:data)
//A1 = username:realm:password
//A2 = http-method:uri
//response = KD( H(A1), nonce:H(A2))
HA1 = md5("user:Streaming Server:test")
HA2 = md5("POST:live/my_stream.sdp")
RESPONSE = md5(HA1+":"+nonce+":"+HA2)
但是使用此代码,我得到响应“0963c3a7b1481523f809e6affa7e792e”和 401 Unauthorized
你能帮助我吗 ?
最佳答案
响应的计算应该是:
HA1 = md5("user:Streaming Server:test")
HA2 = md5("DESCRIBE:/live/my_stream.sdp")
RESPONSE = md5(HA1+":"+nonce+":"+HA2)
以及完整的身份验证字符串:
Authorization: Digest
username="user",
algorithm="MD5",
realm="Streaming Server",
nonce="76bfe6986d3e766424de9bd6e7d3ccc1",
uri="/live/my_stream.sdp",
response="de73283590f7ad76929d20f0d06e914b"
关于authentication - RTSP 身份验证 : digest issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17444635/