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

Wiremock - Cannot Get Response When Request HTTPS

我想模拟像 https://jsonplaceholder.typicode.com. Its proxy and sending by Postman on 8089 port. However when I tried to get request 'https://jsonplaceholder.typicode.com/todos/1 这样的 https 服务'

我收到了;

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

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

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