【问题标题】:How to get HTTPS endpoints to proxy successfully in WireMock?如何在 WireMock 中成功获取 HTTPS 端点代理?
【发布时间】:2017-01-24 19:57:32
【问题描述】:

我正在编写一个内部使用 WireMock 的 HTTP 记录播放代理,但在记录 HTTPS 目标时遇到问题。 HTTP 网站运行良好。

以下是我为未加密站点设置 WireMock 代理的方法:

java \
    -jar /var/proximate/wiremock-standalone-2.4.1.jar \
    --port 9000 \
    --proxy-all http://ilovephp.jondh.me.uk \
    --record-mappings \
    --root-dir /remote/experiment/record/http

然后我可以使用以下命令在该站点上记录任何内容:

wget -e use_proxy=yes -e http_proxy=proximate-proxy:9000 \
    http://ilovephp.jondh.me.uk/en/tutorial/make-your-own-blog

很快我会得到一些自动创建的映射:

/ # ls -R /remote/experiment/record/http
/remote/experiment/record/http:
__files   mappings

/remote/experiment/record/http/__files:
body-tutorial-make-your-own-blog-tWrNm.txt

/remote/experiment/record/http/mappings:
mapping-tutorial-make-your-own-blog-tWrNm.json

这里的内容大致相同,但在 SSL 站点上。代理优先:

java \
    -jar /var/proximate/wiremock-standalone-2.4.1.jar \
    --port 9000 \
    --proxy-all https://www.rottentomatoes.com/ \
    --record-mappings \
    --root-dir /remote/experiment/record/https \
    --verbose

这里是获取:

wget -e use_proxy=yes -e http_proxy=proximate-proxy:9000 \
    https://www.rottentomatoes.com/

WireMock 的结果是创建了内部缓存目录,但它们不包含任何内容:

/ # ls -R /remote/experiment/record/https
/remote/experiment/record/https:
__files   mappings

/remote/experiment/record/https/__files:

/remote/experiment/record/https/mappings:

我在 Docker 容器中的 Alpine 3.4 上使用 WM 2.4.1。我是否需要使用某些https 特定的命令行开关才能使其工作?

更新

看到最近发布的 2.5.0 最近合并了 https-bind-address-bug,我暂时感到欣慰,这听起来非常相关。我已经尝试过这个版本,但不幸的是它没有任何区别。

【问题讨论】:

    标签: java https http-proxy wiremock


    【解决方案1】:

    这已部分解决 - 我的主要错误是 HTTPS 连接的代理地址是分别为 WireMock 和客户端设置的。我现在正在使用:

    java \
        -jar /var/proximate/wiremock-standalone-2.4.1.jar \
        --port 9000 \
        --https-port 9050 \
        --proxy-all https://www.rottentomatoes.com/ \
        --record-mappings \
        --root-dir /remote/experiment/record/https \
        --verbose \
        --print-all-network-traffic
    

    我添加了--print-all-network-traffic,因此我可以查看是否有任何 HTTPS 流量正在访问代理(现在是)。

    这是新的客户端命令,带有新的代理指令:

    wget -e use_proxy=yes -e http_proxy=proximate-proxy:9000 \
         -e https_proxy=proximate-proxy:9050 \
         --verbose \
         --user-agent="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0" \
         https://www.rottentomatoes.com/
    

    但是,现在代理正在实际使用中,看起来操作没有成功完成。我尝试了其他加密网站并收到相同的模糊错误:

    Resolving proximate-proxy... 172.18.0.2
    Connecting to proximate-proxy|172.18.0.2|:9050... connected.
    Failed reading proxy response: No error information
    Retrying.
    
    --2017-01-26 09:20:18--  (try: 2)  https://www.rottentomatoes.com/
    Connecting to proximate-proxy|172.18.0.2|:9050... connected.
    Failed reading proxy response: No error information
    Retrying.
    
    --2017-01-26 09:20:20--  (try: 3)  https://www.rottentomatoes.com/
    Connecting to proximate-proxy|172.18.0.2|:9050... connected.
    Failed reading proxy response: No error information
    Retrying.
    
    ^C
    

    如果有基于标准“wget”字符串的第三方拒绝,我已经替换了用户代理,但这似乎也没有影响。

    我将就此提出一个新问题,以缩小这是 WireMock 还是 Wget 问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-30
      • 1970-01-01
      • 2018-03-05
      • 1970-01-01
      • 1970-01-01
      • 2020-06-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多