@@ -43,8 +43,10 @@ This module provides a class, :class:`ssl.SSLSocket`, which is derived from the
4343:class: `socket.socket ` type, and provides a socket-like wrapper that also
4444encrypts and decrypts the data going over the socket with SSL. It supports
4545additional methods such as :meth: `getpeercert `, which retrieves the
46- certificate of the other side of the connection, and :meth: `cipher `, which
47- retrieves the cipher being used for the secure connection.
46+ certificate of the other side of the connection, :meth: `cipher `, which
47+ retrieves the cipher being used for the secure connection or
48+ :meth: `get_verified_chain `, :meth: `get_unverified_chain ` which retrieves
49+ certificate chain.
4850
4951For more sophisticated applications, the :class: `ssl.SSLContext ` class
5052helps manage settings and certificates, which can then be inherited
@@ -1210,6 +1212,22 @@ SSL sockets also have the following additional methods and attributes:
12101212 .. versionchanged :: 3.9
12111213 IPv6 address strings no longer have a trailing new line.
12121214
1215+ .. method :: SSLSocket.get_verified_chain()
1216+
1217+ Returns verified certificate chain provided by the other
1218+ end of the SSL channel as a list of DER-encoded bytes.
1219+ If certificate verification was disabled method acts the same as
1220+ :meth: `~SSLSocket.get_unverified_chain `.
1221+
1222+ .. versionadded :: 3.13
1223+
1224+ .. method :: SSLSocket.get_unverified_chain()
1225+
1226+ Returns raw certificate chain provided by the other
1227+ end of the SSL channel as a list of DER-encoded bytes.
1228+
1229+ .. versionadded :: 3.13
1230+
12131231.. method :: SSLSocket.cipher()
12141232
12151233 Returns a three-value tuple containing the name of the cipher being used, the
@@ -1656,8 +1674,9 @@ to speed up repeated connections from the same clients.
16561674 Due to the early negotiation phase of the TLS connection, only limited
16571675 methods and attributes are usable like
16581676 :meth: `SSLSocket.selected_alpn_protocol ` and :attr: `SSLSocket.context `.
1659- The :meth: `SSLSocket.getpeercert `,
1660- :meth: `SSLSocket.cipher ` and :meth: `SSLSocket.compression ` methods require that
1677+ The :meth: `SSLSocket.getpeercert `, :meth: `SSLSocket.get_verified_chain `,
1678+ :meth: `SSLSocket.get_unverified_chain ` :meth: `SSLSocket.cipher `
1679+ and :meth: `SSLSocket.compression ` methods require that
16611680 the TLS connection has progressed beyond the TLS Client Hello and therefore
16621681 will not return meaningful values nor can they be called safely.
16631682
@@ -2414,6 +2433,8 @@ provided.
24142433 - :meth: `~SSLSocket.read `
24152434 - :meth: `~SSLSocket.write `
24162435 - :meth: `~SSLSocket.getpeercert `
2436+ - :meth: `~SSLSocket.get_verified_chain `
2437+ - :meth: `~SSLSocket.get_unverified_chain `
24172438 - :meth: `~SSLSocket.selected_alpn_protocol `
24182439 - :meth: `~SSLSocket.selected_npn_protocol `
24192440 - :meth: `~SSLSocket.cipher `
0 commit comments