Commit 15dfc91e authored by Stephane Bortzmeyer's avatar Stephane Bortzmeyer
Browse files

Delete useless test

parent 9d7f2a61
#!/usr/bin/env python3
# https://www.pyopenssl.org/
# https://pyopenssl.readthedocs.io/
import OpenSSL
# http://www.dnspython.org/
import dns.message
import socket
import ctypes
import io
# TODO family-independent socket?
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
message = dns.message.make_query('www.cnam.fr', dns.rdatatype.from_text('A')).to_wire()
# With typical DoT servers, we *must* use TLS 1.2 (otherwise,
# do_handshake fails with "OpenSSL.SSL.SysCallError: (-1, 'Unexpected
# EOF')" Typical HTTP servers are more lax.
context = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_2_METHOD)
session = OpenSSL.SSL.Connection(context, sock)
session.connect(('dot.bortzmeyer.fr', 853))
session.do_handshake()
cert = session.get_peer_certificate()
print("Certificat #%s issued by %s for %s" % (cert.get_serial_number(),
cert.get_issuer(), cert.get_subject()))
length = len(message)
n = session.send(length.to_bytes(2, byteorder='big') + message)
print("%i bytes sent (message is %i bytes)" % (n, length))
buf = session.recv(2)
received = int.from_bytes(buf, byteorder='big')
print("Received %i bytes" % received)
buf = session.recv(received)
response = dns.message.from_wire(buf)
print(response)
session.shutdown()
session.close()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment