How to view Boto3 HTTPS request string
You could also enable debug logging in boto3. That will log all requests and responses as well as lots of other things. Its a bit obscure to enable it:
import boto3boto3.set_stream_logger(name='botocore')
The reason you have to specify botocore
as the name to log is that all of the actual requests and responses happen at the botocore layer.
So what you probably want to do is to send your request through the proxy (mitmproxy, squid). Then check the proxy for what was sent. Since HTTPS data is encrypted you must first decrypt it, then log the response, then encrypt it back and send to AWS. One of the options is to use mitmproxy. ( It's really easy to install )
- Run mitmproxy
Open up another terminal and point proxy to mitmproxys port:
export http_proxy=127.0.0.1:8080export https_proxy=$http_proxy
Then set
verify=False
when creating session/clientIn [1]: import botocore.sessionIn [2]: client = botocore.session.Session().create_client('elasticache', verify=False)
Send request and look at the output of mitmproxy
In [3]: client.describe_cache_engine_versions()
The result should be similar to this:
Host: elasticache.us-east-1.amazonaws.comAccept-Encoding: identityContent-Length: 53Content-Type: application/x-www-form-urlencodedAuthorization: AWS4-HMAC-SHA256 Credential=FOOOOOO/20150428/us-east-1/elasticache/aws4_request, SignedHeaders=host;user-agent;x-amz-date, Signature=BAAAAAARX-Amz-Date: 20150428T213004ZUser-Agent: Botocore/0.103.0 Python/2.7.6 Linux/3.13.0-49-generic
<?xml version='1.0' encoding='UTF-8'?><DescribeCacheEngineVersionsResponsexmlns="http://elasticache.amazonaws.com/doc/2015-02-02/"> <DescribeCacheEngineVersionsResult> <CacheEngineVersions> <CacheEngineVersion> <CacheParameterGroupFamily>memcached1.4</CacheParameterGroupFamily> <Engine>memcached</Engine> <CacheEngineVersionDescription>memcached version 1.4.14</CacheEngineVersionDescription> <CacheEngineDescription>memcached</CacheEngineDescription> <EngineVersion>1.4.14</EngineVersion>