SRFI nnn: Basic TLS connections
Abstract
This SRFI specifies a set of interfaces to establish secure connections to and communicate with peers using the Transport Layer Security (TLS) protocol. It focuses on simplicity over flexibility and is intended to cover typical use cases.
Issues
-
Complete the specification
-
Rethink whether a socket API is mandatory or not
-
Write sample implementations
At least, this SRFI should be able to implement with the following libraries:
-
GnuTLS: widely used, used by Guile
-
Mbed TLS: designed for embedded systems, used by Gauche
-
OpenSSL: widely used, used by Chibi and Chicken
-
A TLS implementation on Java VM (
javax.net.ssl
or Bouncy Castle?) -
A TLS implementation on .NET (
System.Net.Security
or Bouncy Castle?)
Additionally, the following libraries may be taken into account:
-
Amazon s2n-tls
-
Apple Secure Transport
-
axTLS (no commit to the repository since 2019, safe to drop?)
-
BearSSL
-
Microsoft Secure Channel
-
miTLS by Project Everest
-
Mozilla Network Security Services
-
wolfSSL
Rationale
As described in RFC 7258, large-scale surveillance is recognized as a privacy threat nowadays, and the design of internet protocols has been shifting toward encrypted-by-default, using TLS or similar protocols. Thus, a portable API for TLS benefits programmers in writing networking code.
This SRFI is significantly influenced by libtls, a TLS library developed by the OpenBSD community “as a response to the unnecessary challenges other APIs present in order to use them safely.” Furthermore, this SRFI reduces the number of interfaces to provide essential functionalities while supporting various implementations. The interfaces, however, provide room for extensions by future SRFIs and implementations.
This SRFI requires a port I/O API and a socket API that may or may not conform to SRFI 106. It defines feature identifiers (see SRFI 0) and version flags (see SRFI 176).
Specification
The words and phrases “an error is signaled”, “an error that satisfies predicate is signaled”, “an error”, “may report a violation of an implementation restriction”, “unspecified”, “must”, “must not”, “shall”, “shall not”, “should”, “should not”, “may”, “required”, “recommended”, and “optional” in this specification are to be interpreted as described in R7RS, section 1.3.2.
Feature identifiers and version flags
An implementation may provide any or all of the feature identifiers and version flags.
tls-client
Feature identifier: Client interfaces are provided.
tls-server
Feature identifier: Server interfaces are provided.
(tls.name string)
Version flag: The name of TLS implementation.
(tls.version string)
Version flag: The version of TLS implementation.
Configuration interfaces
(tls-configuration? object) → boolean
Procedure: (tls-configuration) → conf
Procedure: (tls-set-protocols conf protocol) → unspecified
Procedure: (tls-set-ciphers conf cipher) → unspecified
Procedure: (tls-set-ca conf port) → unspecified
Procedure: (tls-set-cert conf port) → unspecified
Procedure: (tls-set-crl conf port) → unspecified
Procedure: (tls-set-key conf port) → unspecified
Procedure: (tls-set-keypair conf cert-port key-port) → unspecified
Procedure: (tls-clear-keys conf) → unspecified
Procedure: (tls-set-verify-depth conf depth) → unspecified
Procedure: Context interfaces
(tls-context? object) → boolean
Procedure: (tls-handshake context) → unspecified
Procedure: (tls-input-port context) → port
Procedure: (tls-output-port context) → port
Procedure: (tls-close context) → unspecified
Procedure: (tls-reset context) → unspecified
Procedure: Client interfaces
(tls-client conf) → context
Procedure: (tls-connect-socket context socket servername) → unspecified
Procedure: Server interfaces
(tls-add-keypair conf cert-port key-port) → unspecified
Procedure: (tls-verify-client conf) → unspecified
Procedure: (tls-verify-client-optional conf) → unspecified
Procedure: (tls-server conf) → context
Procedure: (tls-accept-socket context socket) → context
Procedure: Examples
Implementation
??? explanation of how it meets the sample implementation requirement (see process), and the code, if possible, or a link to it.
Acknowledgements
As mentuioned in the rationale, the specification in this SRFI is significantly influenced by libtls. The author wants to acknowledge the LibreSSL developers.
References
IETF RFCs
-
Rescorla, E., “The Transport Layer Security (TLS) Protocol Version 1.3”, RFC 8446, August 2018.
-
Farrell, S. and Tschofenig, H., “Pervasive Monitoring Is an Attack”, BCP 188, RFC 7258, May 2014.
-
Sheffer, Y., Holz, R., and Saint-Andre, P., “Recommendations for Secure Use of Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS)”, BCP 195, RFC 7525, May 2015.
-
Moriarty, K. and Farrell, S., “Deprecating TLS 1.0 and TLS 1.1”, BCP 195, RFC 8996, March 2021.
Manuals
-
Sing, J., et al., “tls_init, tls_config_new, tls_config_free, tls_config_error — initialize TLS client and server API”, tls_init(3), OpenBSD manual pages, July 2018.
-
Vehent, J., et al., “Server Side TLS”, Mozilla Wiki, April 2022. Available at https://wiki.mozilla.org/Security/Server_Side_TLS.
Copyright
Copyright © 2022 Masanori Ogino
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.