• loadrunner处理https请求


    录制到的脚本如下:

    login()

    {

            lr_think_time(10);

            web_url("verifycode.jsp",

                      "URL=https://192.168.211.246:56661/portal/common/jsp/verifycode.jsp?codeSource=loginverifycode&time=1330596177343",

                      "Resource=1",

                      "RecContentType=image/jpeg",

                      "Referer=https://192.168.211.246:56661/portal/indexAction",

                      "Snapshot=t2.inf",

                      LAST);

            web_url("192.168.211.246:38787_2",

                      "URL=http://192.168.211.246:38787/",

                      "Resource=0",

                      "RecContentType=text/html",

                      "Referer=https://192.168.211.246:56661/portal/indexAction",

                      "Snapshot=t3.inf",

                      "Mode=HTML",

                      EXTRARES,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/head/topbg_line.jpg", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/shadowLW.jpg", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/tabM.jpg", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/tabBg.jpg", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/shadowRW.jpg", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/titleHot.gif", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/head/contanta_pic_y.gif", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/titleHot2.gif", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/shadowB.jpg", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      "Url=https://192.168.211.246:56661/portal/common/style/image/titleMyoder.gif", "Referer=https://192.168.211.246:56661/portal/indexAction", ENDITEM,

                      LAST);

            web_url("subscribeInfoQuery.action",

                      "URL=https://192.168.211.246:56661/portal/subscribeInfoQuery.action",

                      "Resource=0",

                      "RecContentType=text/html",

                      "Referer=https://192.168.211.246:56661/portal/indexAction",

                      "Snapshot=t4.inf",

                      "Mode=HTML",

                      LAST);

            return 0;

    }

    思考:是否是loadrunner不支持https

    解决:通过查找一些资料,其实loadrunner支持https协议,但需要在录制脚本时做一些修改,操作步骤如下:

    1、证书的准备

    常见的证书为:*.pfx格式,该种格式的证书可以通过双击运行安装到IE浏览器上。用户在访问的时候就可以使用到。

    但这种证书并不是LoadRunner所使用的类型,因此需要对其进行转换。将其转换为*.pem格式。

    转换方法如下:

    a)        安装openssl后

    b)        运行C:<OpenSSL>/bin文件夹的openssl二进制文件,它将启动OpenSSL命令提示符

    c)        执行以下命令:pkcs12 -in D: est1.pfx -out D: est01.pem–nodes

    d)        执行后,将会在指定目录生成test01.pem文件,这个文件将会在下一个步骤,对LoadRunner进行配置的时候使用到。

    2.LR配置

    启动LoadRunner,打开Recording Option选项。

    [图片]

    留意红色框中的选项。

    选择后,单击New Enty

    [图片]

    红框中的配置为服务器的ip和端口号,按照测试所需要的实际地址进行配置就可以

    配置后,将Use specified client-side certificate[Base64/PEM]钩选,为使用客户端证书访问。

    单击...选择刚刚转换生成的客户端证书。

    [图片]

    如果你为证书有设置密码,在这里也需要输入。

    到此为止所有与http区别的配置就完成了。

    录制后,可以在脚本的开始,看到LoadRunner新生成的语句

    web_set_certificate_ex("CertFilePath=test01.pem",   //密钥文件

                   "CertFormat=PEM",

                   "KeyFilePath=test01.pem",   //密钥文件

                   "KeyFormat=PEM",         

                   "Password=123456",        //密钥密码

                   "CertIndex=1",

                   LAST);

    3、完成上面两步后可以正常录制脚本

    或者使用:

    测webservice遇到https的请求,是在事务开始前加web_set_sockets_option("SSL_VERSION","TLS");

  • 相关阅读:
    Spark完成wordCount
    Spark介绍
    分库分表介绍
    rpc学习
    xgboost应用
    ElasticSearch 批量增加索引
    乡愁
    java futureTask的使用
    ElasticSearch 例子
    Matlab实现线性回归和逻辑回归: Linear Regression & Logistic Regression
  • 原文地址:https://www.cnblogs.com/VseYoung/p/lr.html
Copyright © 2020-2023  润新知