This message was deleted.
# general
s
This message was deleted.
t
Hi @Steve Teplica, provided you start WireMock with browser proxying (which is just forward proxying) enabled, then it will behave in the way you’re asking for. To do this you either do
.enableBrowserProxying(true)
in the Java startup options, or
--enable-browser-proxying
from the CLI.
👀 1
s
It looks like HTTP requests are working fine with this setup. Right now I’m floundering with getting HTTPS requests working. Changes to Spring Application: • I added these JVM proxy settings for HTTPS
Copy code
-Dhttps.proxyHost=localhost
-Dhttps.proxyPort=1083
-Dhttps.nonProxyHosts=
Changes to WireMock Server: • I configured WireMock’s HTTPS port to 1083 • I added a
ConsoleNotifyingWiremockNetworkTrafficListener
to log info on incoming/outgoing network traffic. • These are the current relevent WireMock configurations:
Copy code
WireMockServer wireMockServer = new WireMockServer(WireMockConfiguration.options()
        .port(1080)
        .httpsPort(1083)
        .enableBrowserProxying(true)
        .trustAllProxyTargets(true)
        .preserveHostHeader(true)
        ...
)
Observed behavior: • It looks like the initial HTTP CONNECT request (to open a tunnel to client’s request destination) is closing prematurely or failing:
Copy code
2023-03-29 16:25:53.924 Opened Socket[addr=/127.0.0.1,port=53213,localport=1083]
2023-03-29 16:25:53.930 Incoming bytes: CONNECT <http://subdomain.domain.com:443|subdomain.domain.com:443> HTTP/1.1
Host: <http://subdomain.domain.com:443|subdomain.domain.com:443>
Proxy-Connection: Keep-Alive
User-Agent: okhttp/3.8.1


2023-03-29 16:25:53.938 Outgoing bytes: P
2023-03-29 16:25:53.943 Closed Socket[unconnected]
@Tom Do you have any advice for debugging this further? Or does this appear as an obvious symptom, to you, of something being misconfigured? Any help is greatly appreciated 😄
Extra context on the requested domain: I obfuscated it as
<http://subdomain.domain.com|subdomain.domain.com>
. This is an endpoint that can only be reached while on my corporate network (I’m VPN’d in). The spring application normally sends these requests directly to that endpoint. The spring application does have a keystore and a truststore. I’m not sure if/how those should be used from WireMock
I found this bit on WireMock’s proxying docs. Sounds like this is exactly what I need to do in my situation. Do you have an example of creating two separate HTTPS sessions for this configuration?
t
You’ll need to ensure that the Spring app trusts WireMock’s CA certificate otherwise it’ll (correctly) detect that it’s doing an MITM attack and refuse to send traffic.
1
s
Thanks Tom! The cause of these SSL problems for me was how I configured the java proxy ports. I stumbled across JvmProxyConfigurer in WireMock and saw that it sets
http.proxyPort
and
https.proxyPort
to the same port. So I did the same thing for my spring app, and then everything was working!
👍 1