Wiremock-请求HTTPS时无法获取响应

时间:2019-04-02 14:53:05

标签: https wiremock

我想模拟一个https://jsonplaceholder.typicode.com之类的https服务。它的代理和邮递员在8089端口上发送。但是,当我尝试获取请求'https://jsonplaceholder.typicode.com/todos/1'

我正在得到;

2019-04-02 17:43:28.291 Opened Socket[addr=/127.0.0.1,port=65409,localport=8089]
2019-04-02 17:43:28.362 Incoming bytes: CONNECT jsonplaceholder.typicode.com:443 HTTP/1.1
cache-control: no-cache
User-Agent: PostmanRuntime/7.6.0
Accept: */*
host: jsonplaceholder.typicode.com:443
Connection: close


2019-04-02 17:43:28.363 Closed Socket[addr=/127.0.0.1,port=65409,localport=8089]
2019-04-02 17:43:28.365 Closed Socket[addr=/127.0.0.1,port=65409,localport=8089]

我的Wiremock配置如下所示;

Mac114361:wiremock-standalone berkay.kirmizioglu$ java -jar wiremock-standalone-2.22.0.jar --enable-browser-proxying --https-port=8089 --port=8080 --record-mappings --verbose=true --proxy-all="https://jsonplaceholder.typicode.com" --print-all-network-traffic
2019-04-02 17:43:22.692 Verbose logging enabled
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2019-04-02 17:43:23.483 Verbose logging enabled
2019-04-02 17:43:23.498 Verbose logging enabled
2019-04-02 17:43:23.541 Recording mappings to ./mappings
 /$$      /$$ /$$                     /$$      /$$                     /$$      
| $$  /$ | $$|__/                    | $$$    /$$$                    | $$      
| $$ /$$$| $$ /$$  /$$$$$$   /$$$$$$ | $$$$  /$$$$  /$$$$$$   /$$$$$$$| $$   /$$
| $$/$$ $$ $$| $$ /$$__  $$ /$$__  $$| $$ $$/$$ $$ /$$__  $$ /$$_____/| $$  /$$/
| $$$$_  $$$$| $$| $$  \__/| $$$$$$$$| $$  $$$| $$| $$  \ $$| $$      | $$$$$$/ 
| $$$/ \  $$$| $$| $$      | $$_____/| $$\  $ | $$| $$  | $$| $$      | $$_  $$ 
| $$/   \  $$| $$| $$      |  $$$$$$$| $$ \/  | $$|  $$$$$$/|  $$$$$$$| $$ \  $$
|__/     \__/|__/|__/       \_______/|__/     |__/ \______/  \_______/|__/  \__/

port:                         8080
https-port:                   8089
https-keystore:               jar:file:/Users/berkay.kirmizioglu/Documents/wiremock-standalone/wiremock-standalone-2.22.0.jar!/keystore
proxy-all:                    https://jsonplaceholder.typicode.com
preserve-host-header:         false
enable-browser-proxying:      true
disable-banner:               false
record-mappings:              true
match-headers:                []
no-request-journal:           false
verbose:                      true

1 个答案:

答案 0 :(得分:0)

使用HTTPS / SSL时,建议坚持使用端口443。一方面,因为大多数HTTP实现在使用https://协议时都会默认使用它,而且还因为浏览器或其他HTTP客户端可能不支持默认设置。

在您的示例中,您连接到端口443 CONNECT jsonplaceholder.typicode.com:443,但是在端口8090上运行WireMock。请更改请求或WireMock端口。