Hi Petar,
Thanks for your guide. Now I already can get response from rtsp DESCRIBE command(Need digest auth). And the request and response are as follows:
Request:
DESCRIBE rtsp://20.20.0.154:554/vod/8DF206C2-5E0F-4EB3-A063-F2862A4A4526 RTSP/1.0
Cseq: 3
Authorization: Digest username=“milestone”, realm=“RtspServerLibrary”, nonce=“yFyfSAOWgBmaGil0PwPCGeBHWNhbpGaF”, uri=“rtsp://20.20.0.154:554/vod/8DF206C2-5E0F-4EB3-A063-F2862A4A4526”, response=“e129a81f6712f74c48ccf60f66d8d5c1”
Response:
RTSP/1.0 200 OK
CSeq:
Date: Wed, Oct 21 2020 01:48:51 GMT
Supported: play.basic, play.scale, setup.rtp.rtcp.mux
Content-base: rtsp://20.20.0.154:554/vod/8DF206C2-5E0F-4EB3-A063-F2862A4A4526
Content-type: application/sdp
Content-Length: 264
v=0
o=- 1603244952629091 1 IN IP4 127.0.0.1
s=libRtspServer
c=IN IP4 0.0.0.0
t=0 0
a=tool:libRtspServer 1.0.0
a=range:npt=0.0-89977.9
m=video 0 RTP/AVP 96
a=framerate:1.000000
a=rtpmap:96 H264/90000
a=control:streamid=0
a=fmtp:96 packetization-mode=1;
However, when I issued the next command SETUP, it seems I had to re-do digest auth, and still I always got 401 unauthorized response even though I re-did digest:
Request:
SETUP rtsp://20.20.0.154:554/vod/8DF206C2-5E0F-4EB3-A063-F2862A4A4526/streamid=0 RTSP/1.0
Cseq: 4
Transport: RTP/AVP;UNICAST;client_port=16264-16265;mode=play
Authorization: Digest username=“milestone”, realm=“RtspServerLibrary”, nonce=“yFyfSAOWgBmaGil0PwPCGeBHWNhbpGaF”, uri=“rtsp://20.20.0.154:554/vod/8DF206C2-5E0F-4EB3-A063-F2862A4A4526”, response=“5c2f33ac15a9b2dac41ee2aaa8b728ab”
Response:
RTSP/1.0 401 Unauthorized
CSeq:
Date: Wed, Oct 21 2020 01:48:53 GMT
WWW-Authenticate: Digest realm=“RtspServerLibrary”, nonce=“VybRuZighlmoc1Rsdq7fy9GYyvqMfUwq”
My DESCRIBE and SETUP digest generators are as follows:
private String genResponseValue(String url, String username, String password, String realm,
String nonce) {
String firstPreMd5Value = DigestUtils.md5Hex((username+":"+realm+":"+password));
String firstPostMd5Value = DigestUtils.md5Hex("DESCRIBE:" + url);
return DigestUtils.md5Hex(firstPreMd5Value+":"+nonce+":"+firstPostMd5Value);
}
private String genResponseValue2(String url, String username, String password, String realm, String nonce) {
String firstPreMd5Value = DigestUtils.md5Hex((username+":"+realm+":"+password));
String firstPostMd5Value = DigestUtils.md5Hex("SETUP:" + url);
return DigestUtils.md5Hex(firstPreMd5Value+":"+nonce+":"+firstPostMd5Value);
}
Please help check is the SETUP digest generator correct? If not, please kindly give some advice.
Thank you