使用tomcat自己创建了一个网页.
http://218.197.239.47:8080/First/MyHtml.html
进行了权限设置,使用摘要验证,用户名(root)和密码(admin),输入提示"Test DIGEST"
成功验证后,我们查看响应头和请求头信息如下所示:
其中最重要的信息为请求头中的Authentication首部:
根据摘要认证算,
使用python进行验证:
import md5
username="root"
realm="Test DIGEST" //加密提示
nonce="1443966203108:5d733caba729a7b717e7d767e5f604e4" //服务端发送给客户端的随机数
uri="/First/MyHtml.html" //请求URI
response="8ff4332d9e2790dcd24834d108da113c" //客户端计算得到的hash值
opaque="B7BCDF23435CD63EEA088EAAA88C5857"
qop="auth" //增强保护质量
nc="00000003" //表示客户端已经发送的包含nonce值的次数,如果nc值相同,就表示请求是重放的
cnonce="9fb299a63a5883af" //客户端提供的不透明引用字符串值
A1=username+":"+realm+":"+"admin" //涉及安全信息的数据部分
print "A1=",A1
A1_to_md5=md5.new(A1).hexdigest()
print "A1_to_md5=",A1_to_md5
A2="GET"+":"+uri //与请求相关的数据部分,这是qop为auth时的A2
print "A2=",A2
A2_to_md5=md5.new(A2).hexdigest()
print "A2_to_md5=",A2_to_md5
total=A1_to_md5+":"+nonce+":"+nc+":"+cnonce+":"+qop+":"+A2_to_md5
response_calc=md5.new(total).hexdigest() //根据算法计算的到的hash值
print "response_calc=",response_calc
print "response_calc==response",response_calc==response
运行结果如图所示:
最后我们根据算法流程计算的结果response_calc和浏览器实际得到的结果对比发现,两者是相等的。
可以验证,加密流程就是如算法所描述的一样。