51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3332|回复: 0
打印 上一主题 下一主题

[求助] 求教LR7.8中获得https网页中认证随机数的方法

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2006-9-2 14:15:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求教LR7.8中获得https网页中认证随机数的方法,

我record了个https网页,要做模拟真实的登陆压力测试,发现必须要取得网页上的几个认证产生的随机数,小弟第一次坐这个,不知道怎么搞,那位大大介绍一个方法。下面是我从该页面源码中看到的随机数信息:

<script languang="javascript">
function doSubmit()
{
        WARNING_DATE = 30;        //CA证书的警告提示预警天数

        if(!(document.userform.username.value != "" && document.userform.pwd.value != ""  && document.userform.passwd.value != ""))
        {
                alert("用户名、密码和证书密码不能为空!");
                return false;
        }
        SafeEngineCtl.SEH_InitialSession(2,"c:\\cfets\\UserKey.key",document.userform.passwd.value,0,2,"c:\\cfets\\CertChain.spc","");

        if(SafeEngineCtl.ErrorCode!=0)
        {
                if(SafeEngineCtl.ErrorCode == -2113667069)
                        alert("CA Private Key Password is incorrect");
                else
                {
                        alert("SEH_InitialSession Error. Return:" + SafeEngineCtl.ErrorCode + "\n您可能没有安装证书,请您点击确定,进入下载证书页面!谢谢!");
                        window.location="userlogin/downcert.html";
                }
                return false;
        }

        /* 获取自己证书 */
        strCert = SafeEngineCtl.SEH_GetSelfCertificate(2, "c:\\cfets\\UserCert.der", "");
        if(SafeEngineCtl.ErrorCode != 0)
        {
                alert("SEH_GetSelfCertificate Error. Return:" + SafeEngineCtl.ErrorCode);
                return false;
        }
        document.userform.sCert.value = strCert;

        /* 验证服务器证书 */
        SafeEngineCtl.SEH_VerifyCertificate("MIIFSTCCBLagAwIBAgIDEwBPMAkGBSsOAwIdBQAwggEaMQ0wCwYDVQQGHgQAQwBOMWswaQYDVQQKHmIAQwBoAGkAbgBhACAARgBvAHIAZQBpAGcAbgAgAEUAeABj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wpMD2gO6A5hjdodHRwOi8vMjAwLjMxLjUwLjMxL3NoZWNhLmNvbS9zaGVjYV9jcmwvcmEyMDAxL0NSTDEuY3JsMIIBAAYGKoEcAcU4BIH1MIHyMBwGCCqBHAHFOIEUBBAyMDAuMzEuNDQuMTE6NDQzMCkGCCqBHAHFOIERBB1odHRwOi8vZWNhLmNoaW5hbW9uZXkuY29tLmNuLzAlBggqgRwBxTiBEgQZb2NzcDovLzIwMC4zMS41MC4zNToxODAyMTAjBggqgRwBxTiBEAQXbGRhcDovLzIwMC4zMS41MC4zMTozODkwSgYIKoEcAcU4gRcEPmxkYXA6Ly8yMDAuMzEuNTAuMzE6Mzg5L291PVNoZWNhIENlcnRpZmljYXRlIENoYWluLG89c2hlY2EuY29tMA8GCCqBHAHFOIETBAM3NzIwCQYFKw4DAh0FAAOBgQAlR3zWo4k4geJ1BVktqkY6azouJu58onG7dqutaBjenVUO8ZJyLEVodrjK2pJyWU5ZRqn0hKqN8GP2ZQR+sCZMYONyMCB/1nSJV19KQVmFRNN6neznqU6TOJcOXk7iU9iVKy1UO4i46xZEAKHTrC7AFJZenjKxVZX1s2lWZHu0hA==");       
        if(SafeEngineCtl.ErrorCode!=0)
        {
                if(-2113667054 == SafeEngineCtl.ErrorCode)
                        alert("验证服务器证书错误: 有效期外");
                else
                        alert("验证服务器证书错误:" + SafeEngineCtl.ErrorCode);

                SafeEngineCtl.SEH_ClearSession();
                return false;
        }

        /* 签名随机数 */
        strSigned = SafeEngineCtl.SEH_SignData("494834_RANDOM", 3);       
        if(SafeEngineCtl.ErrorCode!=0)
        {
                alert("SEH_SignData Error. Return:" + SafeEngineCtl.ErrorCode);
                SafeEngineCtl.SEH_ClearSession();
                return false;
        }
        document.userform.sSign.value = strSigned;


        /* 用服务器证书加密随机数 */
        strEnvelope = SafeEngineCtl.SEH_Envelope(1, "494834_RANDOM", "MIIFSTCCBLagAwIBAgIDEwBPMAkGBSsOAwIdBQAwggEaMQ0wCwYDVQQGHgQAQwBO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MSxvdT1zaGVjYSBjcmwsbz1zaGVjYS5jb20/P1NVQj8oY249Q1JMMS5jcmwpMD2gO6A5hjdodHRwOi8vMjAwLjMxLjUwLjMxL3NoZWNhLmNvbS9zaGVjYV9jcmwvcmEyMDAxL0NSTDEuY3JsMIIBAAYGKoEcAcU4BIH1MIHyMBwGCCqBHAHFOIEUBBAyMDAuMzEuNDQuMTE6NDQzMCkGCCqBHAHFOIERBB1odHRwOi8vZWNhLmNoaW5hbW9uZXkuY29tLmNuLzAlBggqgRwBxTiBEgQZb2NzcDovLzIwMC4zMS41MC4zNToxODAyMTAjBggqgRwBxTiBEAQXbGRhcDovLzIwMC4zMS41MC4zMTozODkwSgYIKoEcAcU4gRcEPmxkYXA6Ly8yMDAuMzEuNTAuMzE6Mzg5L291PVNoZWNhIENlcnRpZmljYXRlIENoYWluLG89c2hlY2EuY29tMA8GCCqBHAHFOIETBAM3NzIwCQYFKw4DAh0FAAOBgQAlR3zWo4k4geJ1BVktqkY6azouJu58onG7dqutaBjenVUO8ZJyLEVodrjK2pJyWU5ZRqn0hKqN8GP2ZQR+sCZMYONyMCB/1nSJV19KQVmFRNN6neznqU6TOJcOXk7iU9iVKy1UO4i46xZEAKHTrC7AFJZenjKxVZX1s2lWZHu0hA==");       
        if(SafeEngineCtl.ErrorCode!=0)
        {
                alert("SEH_Envelope(Enc) Error. Return:" + SafeEngineCtl.ErrorCode);
                SafeEngineCtl.SEH_ClearSession();
                return false;
        }
        document.userform.sEnvelope.value = strEnvelope;

        /* 判断证书过期时间并提示 */
        strExpiredDate = SafeEngineCtl.SEH_GetCertDetail(strCert,12);
        today = new Date();
        expiredDate = new Date(strExpiredDate.substring(0,4),strExpiredDate.substring(5,6),strExpiredDate.substring(7,8));
        remainDays = (expiredDate.getYear()*365 + (expiredDate.getMonth()+1)*30 + expiredDate.getDate()) -
                (today.getYear()*365 + (today.getMonth()+1)*30 + today.getDate());
        if(remainDays <= WARNING_DATE)
                alert("您的证书大约" + remainDays + "天后过期,请注意升级");

        /* 获取自己证书的唯一标识
        strUuid = SafeEngineCtl.SEH_GetCertUniqueID(2, "c:\\cfets\\UserCert.der", "");
        if(SafeEngineCtl.ErrorCode != 0)
        {
                alert("SEH_GetCertUniqueID Error. Return:" + SafeEngineCtl.ErrorCode);
                return false;
        }
        document.userform.sUuid.value = strUuid;
        */
       
        /* 释放 */
        SafeEngineCtl.SEH_ClearSession();
        return true;
}
</script>


[ 本帖最后由 Darkcoming 于 2006-9-2 14:16 编辑 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-12 23:57 , Processed in 0.074950 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表