Record & Replay HTTPS requests from Android device

743 views
Skip to first unread message

Jolanda Verhoef

unread,
Jul 28, 2015, 3:54:00 PM7/28/15
to wiremock-user
Hi everyone,

I have the following setup:
- Android emulator with Proxy settings pointing to laptop IP address & wiremock port
- Laptop running standalone Wiremock
- Multiple dynamic third party web services (HAL+JSON), all communication through https.

I would like to record the calls to these web services using wiremock so I can use them for my Calabash tests.

First I tried using the following wiremock setup:
java -jar libs/wiremock-1.57-standalone.jar --port 8898 --https-port 8899 --root-dir wiremock/ --record-mappings --verbose --enable-browser-proxying

This fails with the following exception:
Unrecognized SSL message, plaintext connection?

There are two solutions that I can think of:
1. Make sure the communication between android and laptop is over http instead of https, so I don't have to do the man in the middle attack. I can rewrite my urls to be http on the Android side, but how to rewrite them back to https within Wiremock?
2. Somehow allow forward proxying, by creating certificates, trusting them from the android emulator. I have no idea how this should work.

Could someone point me in the right direction?

Thanks in advance!

Tom Akehurst

unread,
Aug 3, 2015, 5:27:54 PM8/3/15
to wiremock-user
Usually the message you're seeing simply means you're trying to make an HTTP connection the HTTPS port. I'd suggest double checking that the protocol and port in the URLs you're generating are consistent.

abha gupta

unread,
Aug 16, 2016, 6:52:19 PM8/16/16
to wiremock-user

Hello Jolanda,

I know this is an old issue, but could you let me know how could you get past this issue?  I guess, the issue here is, if wiremock is sitting as a proxy between client and server,  how will the https traffic go through it, since wiremock is acting as a man-in-middle in this scenario.. am i correct?

Abha

Jolanda Verhoef

unread,
Aug 17, 2016, 12:32:47 AM8/17/16
to abha gupta, wiremock-user

Hi Abha,

What I did in the end:
- While in recording mode (which is a buildType) , let the Android device do the actual call to the server.
- Forward the response to a local url where wire mock is listening.
- while replaying, rewrite urls to go to the local url to retrieve the recorded responses.

This works, but in my opinion is suboptimal. We decided in the end to stop trying to run tests on the device all together. We rewrote our code in a way that lets us easily junit test everything except for the view layer.

If you have any questions, let me know :)

Jolanda


--
You received this message because you are subscribed to a topic in the Google Groups "wiremock-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wiremock-user/atuqhMf_6tg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wiremock-use...@googlegroups.com.
To post to this group, send email to wiremo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/d3f3db24-30da-42ba-b095-7d7ea360782a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages