Wiremock - Cannot Get Response When Request HTTPS

你说的曾经没有我的故事 提交于 2021-01-29 19:30:40

问题


I want to mock an https service like 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'

I am getting;

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]

My wiremock configuration shown at below;

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:


It is recommended to stick to port 443 when using HTTPS/SSL. For one, because most HTTP implementations will default to it when the https:// protocol is used but also because not doing so may not be supported by browsers or other HTTP clients.

In your example you connect to port 443 CONNECT jsonplaceholder.typicode.com:443 but run WireMock on port 8090. Either change the request or the WireMock port.



来源:https://stackoverflow.com/questions/55477724/wiremock-cannot-get-response-when-request-https

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!