TLS message callback The message callback provides a debugging hook to analyze TLS connections. The callback is called for any TLS protocol message (header, handshake, alert, and more), but not for application data. Due to technical limitations, the callback can't b
(self)
| 579 | |
| 580 | @property |
| 581 | def _msg_callback(self): |
| 582 | """TLS message callback |
| 583 | |
| 584 | The message callback provides a debugging hook to analyze TLS |
| 585 | connections. The callback is called for any TLS protocol message |
| 586 | (header, handshake, alert, and more), but not for application data. |
| 587 | Due to technical limitations, the callback can't be used to filter |
| 588 | traffic or to abort a connection. Any exception raised in the |
| 589 | callback is delayed until the handshake, read, or write operation |
| 590 | has been performed. |
| 591 | |
| 592 | def msg_cb(conn, direction, version, content_type, msg_type, data): |
| 593 | pass |
| 594 | |
| 595 | conn |
| 596 | :class:`SSLSocket` or :class:`SSLObject` instance |
| 597 | direction |
| 598 | ``read`` or ``write`` |
| 599 | version |
| 600 | :class:`TLSVersion` enum member or int for unknown version. For a |
| 601 | frame header, it's the header version. |
| 602 | content_type |
| 603 | :class:`_TLSContentType` enum member or int for unsupported |
| 604 | content type. |
| 605 | msg_type |
| 606 | Either a :class:`_TLSContentType` enum number for a header |
| 607 | message, a :class:`_TLSAlertType` enum member for an alert |
| 608 | message, a :class:`_TLSMessageType` enum member for other |
| 609 | messages, or int for unsupported message types. |
| 610 | data |
| 611 | Raw, decrypted message content as bytes |
| 612 | """ |
| 613 | inner = super()._msg_callback |
| 614 | if inner is not None: |
| 615 | return inner.user_function |
| 616 | else: |
| 617 | return None |
| 618 | |
| 619 | @_msg_callback.setter |
| 620 | def _msg_callback(self, callback): |