<html><body><p><font size="2">Hi Rien,</font><br><br><font size="2">This is great, thanks for referencing your blogs/repo. I'll go through them.<br>(An unfortunate issue I have found with security is that, we need it, we expect it, but we don't want to worry about it :-)</font><br><br><font size="2">The basic structure of what we are considering right now would to a large extent follow that of </font><br><a href="https://github.com/IBM-Swift/BlueSSLService/"><font size="2">https://github.com/IBM-Swift/BlueSSLService/</font></a><br><font size="2">which invokes SecureTransport on Apple and OpenSSL on Linux. </font><br><br><font size="2">For more details of some of the discussions, just follow this thread.</font><br><a href="https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170320/000298.html"><font size="2">https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170320/000298.html</font></a><br><br><font size="2">Would love to have your contributions here! :-D</font><br><br><font size="2">gelareh</font><br><br><br><br><br><img width="16" height="16" src="cid:1__=8FBB0A69DFE12B498f9e8a93df938690918c8FB@" border="0" alt="Inactive hide details for Rien ---04/06/2017 11:54:57 AM---Having just finished a client/server framework that builds on openSS"><font size="2" color="#424282">Rien ---04/06/2017 11:54:57 AM---Having just finished a client/server framework that builds on openSSL I sympathise with this proposa</font><br><br><font size="2" color="#5F5F5F">From:        </font><font size="2">Rien &lt;Rien@Balancingrock.nl&gt;</font><br><font size="2" color="#5F5F5F">To:        </font><font size="2">Gelareh Taban/Austin/IBM@IBMUS</font><br><font size="2" color="#5F5F5F">Cc:        </font><font size="2">swift-evolution@swift.org</font><br><font size="2" color="#5F5F5F">Date:        </font><font size="2">04/06/2017 11:54 AM</font><br><font size="2" color="#5F5F5F">Subject:        </font><font size="2">Re: [swift-evolution] [Pitch] Cross-platform Swift TLS library</font><br><hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br><br><br><tt><font size="2">Having just finished a client/server framework that builds on openSSL I sympathise with this proposal.<br><br>However, I wrote a few blogposts about my experiences with openSSL. And those leads me to believe that there is not much interest in secure networking. The number of hits on those posts are quite low (anaemic even) when compared to -for example- posts on socket programming.<br><br>While the sketch you made below does not sound too bad, I am afraid that the API will become complex so fast, that it will not be much easier to use than openSSL/LibreSSL etc. But don’t let that stop you ;-)<br><br>Regards,<br>Rien<br><br>PS: </font></tt><tt><font size="2"><a href="https://github.com/Balancingrock/SecureSockets">https://github.com/Balancingrock/SecureSockets</a></font></tt><tt><font size="2"><br><br><br>Site: </font></tt><tt><font size="2"><a href="http://balancingrock.nl">http://balancingrock.nl</a></font></tt><tt><font size="2"><br>Blog: </font></tt><tt><font size="2"><a href="http://swiftrien.blogspot.com">http://swiftrien.blogspot.com</a></font></tt><tt><font size="2"><br>Github: </font></tt><tt><font size="2"><a href="http://github.com/Balancingrock">http://github.com/Balancingrock</a></font></tt><tt><font size="2"><br>Project: </font></tt><tt><font size="2"><a href="http://swiftfire.nl">http://swiftfire.nl</a></font></tt><tt><font size="2">&nbsp;- A server for websites build in Swift<br><br><br><br><br><br><br>&gt; On 06 Apr 2017, at 18:16, Gelareh Taban via swift-evolution &lt;swift-evolution@swift.org&gt; wrote:<br>&gt; <br>&gt; Hi all,<br>&gt; <br>&gt; I’d like to pitch some of the ideas that have been discussed in the server working group around security. <br>&gt; <br>&gt; To get more information on the server API group and its goals, see </font></tt><tt><font size="2"><a href="https://swift.org/server-apis/">https://swift.org/server-apis/</a></font></tt><tt><font size="2">. (TL;DR version is to come up with a set of foundational APIs that work cross-platform, on all platforms supported by Swift, including Linux.) <br>&gt; <br>&gt; For security, we have divided the scope into SSL/TLS support and crypto support. Our first goal and the subject of this pitch is TLS. This current pitch is the result of various discussions that have taken place over the past several months over the server working group mailing list and several projects by groups such as Vapor, IBM, Zewo, etc. <br>&gt; <br>&gt; Our plan is to start with the main ideas presented here and work on a Swift library that we prototype and iterate on before finalizing on a specific interface. Hopefully the ideas in this pitch are non-controversial, aside from the naming of the method and protocols (which is widely accepted as a `hard` problem).<br>&gt; <br>&gt; # Problem<br>&gt; <br>&gt; Since there is currently no standard Swift SSL/TLS library that is compatible on both Apple and Linux, Swift projects use their TLS library of choice (such as OpenSSL, LibreSSL, Security framework, etc). This results in:<br>&gt; - fragmentation of the space as well as incompatibility of project dependencies if more than one security package is needed by different modules (a project cannot have both OpenSSL and LibreSSL in its dependency graph)<br>&gt; - insecurity (using an unpatched or deprecated library such as OpenSSL on macOS)<br>&gt; - unmaintainablity (using non-standard or non-native libraries)<br>&gt; - more complex code (using different APIs or code paths for each platform).<br>&gt; <br>&gt; So we want to propose a standard set of protocols that define the behavior of the TLS service and how the application and the server and networking layers beneath it interact with the TLS service. What complicates this pitch is that the Swift in server space is new and none of the interfaces have yet been defined, so this is really a work in iteration.<br>&gt; <br>&gt; # Design goals<br>&gt; <br>&gt; We came up with the following design goals for a solution:<br>&gt; <br>&gt; - Provide a consistent and unified Swift interface so that the developer can write simple, cross-platform applications;<br>&gt; - Don't implement new crypto functionality and instead use existing functions in underlying libraries;<br>&gt; - Plug-n-play architecture which allows the developer to decide on underlying security library of choice, e.g., OpenSSL vs LibreSSL;<br>&gt; - Library should be agnostic of the transport mechanism (e.g., socket, etc), whilst allowing for both blocking and non-blocking connections;<br>&gt; - Developers should be able to use the same TLS library for both client and server applications.<br>&gt; <br>&gt; <br>&gt; # Proposal<br>&gt; <br>&gt; The proposed solution basically defines a number of protocols for each interface:<br>&gt; - Transport management<br>&gt; - TLS management<br>&gt; <br>&gt; A basic diagram that shows the relationship between the proposed protocols is shown below:<br>&gt; <br>&gt; (See attached file: TLSServiceArchitecture.png)<br>&gt; <br>&gt; ![alt text](</font></tt><tt><font size="2"><a href="https://raw.githubusercontent.com/gtaban/blogs/master/TLSServiceArchitecture.png">https://raw.githubusercontent.com/gtaban/blogs/master/TLSServiceArchitecture.png</a></font></tt><tt><font size="2">&nbsp;&quot;Architecture of TLSService modules&quot;)<br>&gt; <br>&gt; <br>&gt; The transport management protocol essentially would be a combination of a connection object (e.g., a socket pointer, a file descriptor, etc) and a connection type.<br>&gt; <br>&gt; This is the connection object that gets passed to the implementation of the TLS service protocol, which also handles the read and write callbacks to the connection object.<br>&gt; <br>&gt; The TLS service protocol would define a sets of methods that deal with TLS setup (certificates, server/client, etc), and TLS events (such as receiving data, encrypting and writing to connection object or reading from a connection object, decrypting and returning the data).<br>&gt; These methods are implemented by the TLS service which in turn uses its choice of underlying security library. As an example, the TLS service uses SecureTransport library on Apple platform and OpenSSL on Linux. <br>&gt; <br>&gt; ## How this would work<br>&gt; <br>&gt; If an application requires TLS for its use case, it creates a TLS service object and configures it based on its requirements.<br>&gt; <br>&gt; The application then passes the TLS service object to its lower level frameworks that deal with networking and communication. Each lower level framework maintains an optional instance variable of type TLS service protocol. If the optional variable exists, it is further passed down until it gets to the lowest level that deals with the Swift transport layer APIs (in the diagram above, this is the HTTP Management layer). When this layer creates the connection using the transport layer APIs, it assigns the TLS service object to the transport layer delegate. The Swift socket layer is then responsible for calling the TLS service protocol methods that handle the TLS functionality at the appropriate times. <br>&gt; <br>&gt; <br>&gt; # Source Compatibility:<br>&gt; <br>&gt; As mentioned, the Swift in server space is still new and the interfaces are currently under discussion. Although the proposed protocols are designed to be as non-breaking as possible, they do place several assumptions on the rest of the transport/application stack. <br>&gt; <br>&gt; - The application layer must import and instantiate a TLS service object which implements the TLS service protocol if it wants to enable TLS service.<br>&gt; - Every framework layer above the transport management layer but below the application layer (which includes HTTP and server frameworks) has an optional object that implements the TLS service protocol. If the TLS object exists, it is passed down to each layer below.<br>&gt; - The HTTP layer which sets up the transport management layer assigns the TLS object to the transport management delegate if the object exists. <br>&gt; - The transport management layer which sets up the I/O communication implements the transport management protocol.<br>&gt; - The transport management layer which sets up the I/O communication and deals with the low level C system I/O, calls the appropriate TLS service protocol methods whenever I/O data needs to be secured.<br>&gt; - The long term goal for the location of the TLS service protocol is within the Foundation framework. In the short term, the protocol can live within the transport management framework.<br>&gt; <br>&gt; &lt;TLSServiceArchitecture.png&gt;_______________________________________________<br>&gt; swift-evolution mailing list<br>&gt; swift-evolution@swift.org<br>&gt; </font></tt><tt><font size="2"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></font></tt><tt><font size="2"><br><br></font></tt><br><br><BR>
</body></html>