@@ -43,8 +43,10 @@ This module provides a class, :class:`ssl.SSLSocket`, which is derived from the
43
43
:class: `socket.socket ` type, and provides a socket-like wrapper that also
44
44
encrypts and decrypts the data going over the socket with SSL. It supports
45
45
additional 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.
48
50
49
51
For more sophisticated applications, the :class: `ssl.SSLContext ` class
50
52
helps manage settings and certificates, which can then be inherited
@@ -1210,6 +1212,22 @@ SSL sockets also have the following additional methods and attributes:
1210
1212
.. versionchanged :: 3.9
1211
1213
IPv6 address strings no longer have a trailing new line.
1212
1214
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
+
1213
1231
.. method :: SSLSocket.cipher()
1214
1232
1215
1233
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.
1656
1674
Due to the early negotiation phase of the TLS connection, only limited
1657
1675
methods and attributes are usable like
1658
1676
: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
1661
1680
the TLS connection has progressed beyond the TLS Client Hello and therefore
1662
1681
will not return meaningful values nor can they be called safely.
1663
1682
@@ -2414,6 +2433,8 @@ provided.
2414
2433
- :meth: `~SSLSocket.read `
2415
2434
- :meth: `~SSLSocket.write `
2416
2435
- :meth: `~SSLSocket.getpeercert `
2436
+ - :meth: `~SSLSocket.get_verified_chain `
2437
+ - :meth: `~SSLSocket.get_unverified_chain `
2417
2438
- :meth: `~SSLSocket.selected_alpn_protocol `
2418
2439
- :meth: `~SSLSocket.selected_npn_protocol `
2419
2440
- :meth: `~SSLSocket.cipher `
0 commit comments