Hi all,
We (@jvdprng and myself) are planning to resurrect the previously withdrawn PEP 543 as part of our work with the Sovereign Tech Fund. To this end, we have looked at the history of this PEP, considered what has changed since it was actively worked on, and are planning to open a PR for a new PEP with some proposed changes that we will summarize below.
We believe that the problems that PEP 543 aims to solve remain largely the same. The PEP lists five bullet points, and since its withdrawal, only the fourth bullet point related to the use of system trust stores has been addressed (by the truststore package).
The goals are roughly the same as described in PEP 543:
- To provide a common API surface for both core and third-party developers to target their TLS implementations to. This allows TLS developers to provide interfaces that can be used by most Python code, and allows network developers to have an interface that they can target that will work with a wide range of TLS implementations. As an additional goal, this API should be as simple as possible, preventing users from making insecure choices.
- To provide an API that has few or no OpenSSL-specific concepts leak through. The ssl module today has a number of warts caused by leaking OpenSSL concepts through to the API: the new Protocol classes would remove those specific concepts.
- To provide a path for the core development team to make OpenSSL one of many possible TLS backends, rather than requiring that it be present on a system in order for Python to have TLS support.
Our draft PEP includes the following changes to the interfaces compared to PEP 543:
- Remove the concept of a wrapped socket. Based on this post on the Python discussion boards and the following post, it seems that this concept is no longer desirable and/or necessary. Instead, the backend will create a socket-like object, wrap it, and return it to the user. The socket should be non-blocking to enable sans-io abstractions.
- Change the ABCs to Protocols, and add extensive typing information.
- Remove support for all deprecated features:
- All protocol versions except TLS v1.2 and v1.3
- Next protocol negotiation using NPN
- Removed all TLS v1.2 cipher suite definitions except for modern, forward secure ones (though users can still use older cipher suites by providing the integer value)
- Disallow insecure user choices:
- Server authentication is always enabled for clients. It is not possible to disable this.
- Clients will either use the system trust store by default, or their own if provided.
- Simplify the API further by:
- Splitting client and server configuration. Due to the asymmetry in client versus server authentication, we believe it best to split these two objects.
- Removing the SNI callback function. The implementations should transparently handle SNI based on a set of certificates provided by the caller.
- Removing password-protected private keys as an option. It violates separation of concerns and compels backends to support a something that’s orthogonal to TLS itself (PKCS#8 decapsulation with several very mediocre KDFs).
Any feedback is welcome! We hope to understand whether any of our proposals would negatively impact current users of the ssl package or future developers of TLS-backends.
We are also wondering whether this should be in a single PEP or whether it should be split into two PEPs: one focusing exclusively on the client side (i.e. server authentication) and another focusing on the server side (i.e. client auth). The client side (= server auth) is likely the most urgent, the most impactful, and the least complex, and we’re happy to scope this PEP down to just those components if doing so will make things easier for the CPython team to evaluate!
(Our current plan is to submit the text of the draft PEP itself once we get a PEP-Delegate here. But if it’s easier/more correct to submitted the draft and share our example implementation before that, we’re happy to do that as well! Also, please let us know if we’ve mis-categorized this by putting this into the Core Development stream instead of the PEPs one.)
+CCing @sethmlarson in his capacity as SDIR and truststore
maintainer as well