Пример #1
0
 def close_session(self):
     self.add_record()
     self.add_msg(TLSAlert(level=1, descr=0))
     try:
         self.flush_records()
     except:
         self.vprint("Could not send termination Alert, maybe the server stopped?")  # noqa: E501
     raise self.FINAL()
Пример #2
0
 def TLS13_MISSING_CLIENTCERTIFICATE(self):
     self.vprint("Missing ClientCertificate!")
     self.add_record()
     self.add_msg(TLSAlert(level=2, descr=0x74))
     self.flush_records()
     self.vprint("Sending TLSAlert 116")
     self.socket.close()
     raise self.WAITING_CLIENT()
Пример #3
0
 def close_session(self):
     self.add_record()
     self.add_msg(TLSAlert(level=1, descr=0))
     try:
         self.flush_records()
     except:
         self.vprint("Could not send termination Alert, maybe the client left?")
         self.buffer_out = []
     self.socket.close()
     raise self.WAITING_CLIENT()
Пример #4
0
 def NO_USABLE_CIPHERSUITE(self):
     """
     If there is no available cipher suite, close the session with an Alert.
     """
     print "No usable cipher suite, closing connection"
     self.cur_pkt = TLS(type=21, msg=[], tls_session=self.cur_session)
     p = TLSAlert(level=1, descr=0)
     self.cur_pkt.msg.append(p)
     self.socket.send(str(self.cur_pkt))
     self.cur_pkt = None
Пример #5
0
 def close_session_final(self):
     self.add_record()
     self.add_msg(TLSAlert(level=1, descr=0))
     try:
         self.flush_records()
     except:
         self.vprint("Could not send termination Alert, maybe the client left?")
     # We might call shutdown, but unit tests with s_client fail with this.
     #self.socket.shutdown(1)
     self.socket.close()
     raise self.FINAL()
Пример #6
0
 def close_session(self):
     """
     We end the session properly after 2 seconds,
     with a TLS Alert (warning, close_notify).
     """
     time.sleep(2)
     self.cur_pkt = TLS(type=21, msg=[], tls_session=self.cur_session)
     p = TLSAlert(level=1, descr=0)
     self.cur_pkt.msg.append(p)
     try:
         self.socket.send(str(self.cur_pkt))
     except:
         print "Could not send termination Alert (maybe the server stopped)"
     self.cur_pkt = None
Пример #7
0
def build_tls_alert(alert_level, alert_descr):
    """
    Build a TLS Alert using the given Alert level and description.
    """

    return TLSAlert(level=alert_level, descr=alert_descr)