dlenski / rsa_ct_kip

Provision an RSA SecurID token with RSA's CT-KIP protocol
MIT License
41 stars 8 forks source link

Verbose mode: Print full final server response #5

Closed cemeyer closed 5 years ago

cemeyer commented 5 years ago

It is needed to examine XML contents; the processed response just prints an opaque Python object pointer, which isn't useful after the process has exited.

dlenski commented 5 years ago

Thanks. I can commit this if you really want the raw base64-and-SOAP-ified response, but if you just want the plain XML of the interesting parts, how about this instead?

diff --git a/rsa_ct_kip/client.py b/rsa_ct_kip/client.py
index 4f3395a..89382be 100755
--- a/rsa_ct_kip/client.py
+++ b/rsa_ct_kip/client.py
@@ -112,7 +112,7 @@ def main(args=None):
         print(raw_res1.text)
     pd_res1, res1 = soap.parse_ServerResponse(raw_res1)
     if args.verbose:
-        print(res1)
+        print(ET.tostring(res1))

     session_id = res1.attrib['SessionID']
     k = res1.find('EncryptionKey/dsig:KeyValue/dsig:RSAKeyValue', ns)
@@ -139,9 +139,11 @@ def main(args=None):
     req2 = soap.make_ClientRequest('ServerFinished', pd, req2_filled)
     print("Sending ServerFinished request to server, with encrypted client nonce...")
     raw_res2 = s.send(s.prepare_request(req2))
+    if args.verbose:
+        print(raw_res2.text)
     pd_res2, res2 = soap.parse_ServerResponse(raw_res2)
     if args.verbose:
-        print(res2)
+        print(ET.tostring(res2))

     # get stuff from response
     service_id = get_text(res2.find('ServiceID'))
cemeyer commented 5 years ago

I think it'd be good to have raw too. We do it for msg1.

cemeyer commented 5 years ago

:+1: