zoukankan      html  css  js  c++  java
  • loadrunner支持https协议的操作方法-经验总结

    问题:用户portal支持https协议,用loadrunner录制登陆脚本时发现未录制到用户名和密码

     

    录制到的脚本如下:

    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.pemnodes

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

     

    2LR配置

    启动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");

  • 相关阅读:
    谁能撼动C语言的霸主地位?是Go?是Rust?还是...
    从入职到快速晋升,程序员能够从底层逆袭,究竟是什么原因?
    我敢说,这8个Linux基础命令,学了绝不吃亏!(强烈推荐)
    想从程序员到百万高管,你一定要避开这3个坑!(年轻人必读)
    注意!在Linux中删除特殊名称文件有这6种方式!(建议收藏)
    事实证明!这10个Linux系统操作指令,简直 “不讲武德” ,请大家耗子尾汁!
    最适合单片机编程的高级语言,除了C语言,别无选择!
    “Help”!如何学习C和C++才不茫然,才不是乱学?
    C语言丨不要阅读此文,除非你已掌握二叉树的这些操作
    团队编程项目作业2-团队编程项目开发环境搭建过程
  • 原文地址:https://www.cnblogs.com/HCT118/p/5377231.html
Copyright © 2011-2022 走看看