使用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" //请求URIresponse="8ff4332d9e2790dcd24834d108da113c" //客户端计算得到的hash值opaque="B7BCDF23435CD63EEA088EAAA88C5857"qop="auth" //增强保护质量nc="00000003" //表示客户端已经发送的包含nonce值的次数,如果nc值相同,就表示请求是重放的cnonce="9fb299a63a5883af" //客户端提供的不透明引用字符串值A1=username+":"+realm+":"+"admin" //涉及安全信息的数据部分print "A1=",A1A1_to_md5=md5.new(A1).hexdigest()print "A1_to_md5=",A1_to_md5A2="GET"+":"+uri //与请求相关的数据部分,这是qop为auth时的A2print "A2=",A2A2_to_md5=md5.new(A2).hexdigest()print "A2_to_md5=",A2_to_md5total=A1_to_md5+":"+nonce+":"+nc+":"+cnonce+":"+qop+":"+A2_to_md5response_calc=md5.new(total).hexdigest() //根据算法计算的到的hash值print "response_calc=",response_calcprint "response_calc==response",response_calc==response
运行结果如图所示:
最后我们根据算法流程计算的结果response_calc和浏览器实际得到的结果对比发现,两者是相等的。
可以验证,加密流程就是如算法所描述的一样。
本文详细介绍了如何在Tomcat中创建网页,并通过摘要验证实现安全登录。接着,利用Python代码对摘要认证过程进行验证,确保验证流程正确无误。
957

被折叠的 条评论
为什么被折叠?



