From 71aba94cf046d40bbc758fe3e2490425488d55e2 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Sat, 7 Nov 2015 18:22:02 +0100 Subject: [PATCH] Add xmpp check --- tls-check | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tls-check b/tls-check index 4610063..d8bdc9b 100644 --- a/tls-check +++ b/tls-check @@ -3,7 +3,7 @@ from __future__ import print_function from optparse import OptionParser from ssl import SSLContext, PROTOCOL_TLSv1_2, CERT_REQUIRED, cert_time_to_seconds, SSLError, CertificateError -from socket import socket, AF_INET6 +from socket import socket, AF_INET6, create_connection from datetime import datetime, timedelta from smtplib import SMTP import yaml @@ -23,7 +23,29 @@ class Verifier: if hasattr(self, 'remote_check_%s' % proto): getattr(self, 'remote_check_%s' % proto)(context, host, port, name) - def remote_check_smtp(self, context, host, port): + def remote_check_xmpp(self, context, host, port, name): + xmpp_open = ("" ) + xmpp_starttls = "" + + connection = create_connection((host, port)) + connection.sendall(xmpp_open.format(name).encode('utf-8')) + response = connection.recv(4096).decode('utf-8') + + if not '' in response: + response = response + connection.recv(4096).decode('utf-8') + + connection.sendall(xmpp_starttls.encode('utf-8')) + response = response + "\n\n" + connection.recv(4096).decode('utf-8') + + connection = context.wrap_socket(connection, server_hostname=name) + connection.do_handshake() + + cert = connection.getpeercert() + return self.check_cert(cert, host, port, name) + + def remote_check_smtp(self, context, host, port, name): smtp = SMTP(host, port) try: smtp.starttls(context=context) -- 2.39.5