Debugging Wreq/http-client https requests

I have a program that is POST'ing some data to a remote server. However, some part of the data I'm sending is wrong I believe. If this were plain http without encryption, wireshark would allow me to see the exact data being sent over the wire. However, with https it is encrypted. Is there an inbuilt way to debug requests sent by wreq or more likely, a way to output debug info for http-client? Alternatively, is there a way to use NSS support with either of these libraries: http://security.stackexchange.com/questions/35639/decrypting-tls-in-wireshar... Thanks in advance to all for your time.

We can certainly make this process more official/easier to use, but
http-client does support this. Manager has a field mTlsConnection which
specifies how to create a Connection value to a TLS server. Connection is a
relatively simple datatype that specifies what to do, e.g., when sending
data to a server. If you wanted to log all of that writes to a file, you
might do something like:
mOrig <- newManager tlsManagerSettings
let m = mOrig
{ mTlsConnection = \ha h p -> do
connOrig <- mTlsConnection mOrig ha h p
return connOrig { connectionWrite = \bs -> do
S.appendFile "/tmp/log" bs
connectionWrite connOrig bs
}
}
On Sat, Nov 1, 2014 at 1:16 AM, Cody Goodman
I have a program that is POST'ing some data to a remote server. However, some part of the data I'm sending is wrong I believe.
If this were plain http without encryption, wireshark would allow me to see the exact data being sent over the wire. However, with https it is encrypted.
Is there an inbuilt way to debug requests sent by wreq or more likely, a way to output debug info for http-client?
Alternatively, is there a way to use NSS support with either of these libraries:
http://security.stackexchange.com/questions/35639/decrypting-tls-in-wireshar...
Thanks in advance to all for your time. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Thanks for the example Michael, I ended up skipping cert checks but
it's nice to know how to override the tlsConnection like this.
On Sat, Nov 1, 2014 at 11:50 AM, Michael Snoyman
We can certainly make this process more official/easier to use, but http-client does support this. Manager has a field mTlsConnection which specifies how to create a Connection value to a TLS server. Connection is a relatively simple datatype that specifies what to do, e.g., when sending data to a server. If you wanted to log all of that writes to a file, you might do something like:
mOrig <- newManager tlsManagerSettings let m = mOrig { mTlsConnection = \ha h p -> do connOrig <- mTlsConnection mOrig ha h p return connOrig { connectionWrite = \bs -> do S.appendFile "/tmp/log" bs connectionWrite connOrig bs } }
On Sat, Nov 1, 2014 at 1:16 AM, Cody Goodman
wrote: I have a program that is POST'ing some data to a remote server. However, some part of the data I'm sending is wrong I believe.
If this were plain http without encryption, wireshark would allow me to see the exact data being sent over the wire. However, with https it is encrypted.
Is there an inbuilt way to debug requests sent by wreq or more likely, a way to output debug info for http-client?
Alternatively, is there a way to use NSS support with either of these libraries:
http://security.stackexchange.com/questions/35639/decrypting-tls-in-wireshar...
Thanks in advance to all for your time. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi,
I ended up skipping cert checks
Please don't! Skipping certificate checks is bad. Man in the middle attacks (mitm) are real in the internet. Generating your own certificate is pretty easy on unix-like os'es and you will only have to do it once anyway. Search for certificate authority and openssl and you will find many examples on how to do it. Cheers, tobias florek

You can use mitmproxy with a self-generated certificate. That will
work even if you can't control the URL where the app sends the
requests to, simply add the hostname to your /etc/hosts and point it
to 127.0.0.1.
On Sat, Nov 1, 2014 at 12:16 AM, Cody Goodman
I have a program that is POST'ing some data to a remote server. However, some part of the data I'm sending is wrong I believe.
If this were plain http without encryption, wireshark would allow me to see the exact data being sent over the wire. However, with https it is encrypted.
Is there an inbuilt way to debug requests sent by wreq or more likely, a way to output debug info for http-client?
Alternatively, is there a way to use NSS support with either of these libraries:
http://security.stackexchange.com/questions/35639/decrypting-tls-in-wireshar...
Thanks in advance to all for your time. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I did end up using mitmproxy. However I didn't know about generating
my own certificate and made wreq ignore certificate settings. Your
solution is better I think, thanks.
On Mon, Nov 3, 2014 at 4:09 AM, Tomas Carnecky
You can use mitmproxy with a self-generated certificate. That will work even if you can't control the URL where the app sends the requests to, simply add the hostname to your /etc/hosts and point it to 127.0.0.1.
On Sat, Nov 1, 2014 at 12:16 AM, Cody Goodman
wrote: I have a program that is POST'ing some data to a remote server. However, some part of the data I'm sending is wrong I believe.
If this were plain http without encryption, wireshark would allow me to see the exact data being sent over the wire. However, with https it is encrypted.
Is there an inbuilt way to debug requests sent by wreq or more likely, a way to output debug info for http-client?
Alternatively, is there a way to use NSS support with either of these libraries:
http://security.stackexchange.com/questions/35639/decrypting-tls-in-wireshar...
Thanks in advance to all for your time. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Cody Goodman
-
Michael Snoyman
-
Tobias Florek
-
Tomas Carnecky