SSL and TLS Protocols
SSL stands for Secure Sockets Layer and was originally created by Netscape. SSLv2 and SSLv3 are the 2 versions of this protocol (SSLv1 was never publicly release). After SSLv3, SSL was renamed to TLS.
TLS stands for Transport Layer Security and started with TLSv1.0 which is an upgraded version of SSLv3.
Those protocols are standardized and described by RFCs.
OpenSSL provides an implementation for those protocols and is often used as the reference implementation for any new feature.
The goal of SSL was to provide secure communication using classical TCP sockets with very few changes in API usage of sockets to be able to leverage security on existing TCP socket code.
SSL/TLS is used in every browser worldwide to provide https ( http secure ) functionality.
The latest standard version is TLSv1.2 http://tools.ietf.org/html/rfc5246, while the upcoming TLS v1.3 is still draft.
Connectionless support is provided via DTLS.
Those protocols are configurable and can use various ciphers depending on their version.
- 1 Security
- 2 Handshake
- 3 Session Resumption
- 4 Renegotiation
- 5 TLS Extensions
- 6 Server Authentication
- 7 Client Authentication
- 8 Alternate Authentication Methods
Besides implementation problems leading to security issues, there is security inherent to the protocol itself.
It is recommended to run TLSv1.0, 1.1 or 1.2 and fully disable SSLv2 and SSLv3 that have protocol weaknesses.
For the very same reason it is recommended to control protocol downgrade.
POODLE : SSLv3 harmful
Signaling cipher suite value (SCSV), i.e., it does not actually correspond to a suite of cryptosystems. Its presence is used to signal some facts or contextual information allowing it to not break existing implementations that just ignore this unsupported cipher suite.
SCSV was created with TLS_EMPTY_RENEGOTIATION_INFO_SCSV in rfc5746 draft. http://tools.ietf.org/html/rfc5746#section-3.3 Usage of a cipher suite value is explained by the fact that some SSLv3 and TLSv1.0 implementations fail to ignore extensions that they do not support, so using a cipher suite allows the bypass of these implementation problems.
- TLS_EMPTY_RENEGOTIATION_INFO_SCSV 0x00 0xFF
openssl : SSL3_CK_SCSV
- TLS_FALLBACK_SCSV 0x56 0x00 See SSL MODE SEND FALLBACK SCSV
openssl : SSL3_CK_FALLBACK_SCSV
A connection always starts with a handshake between a client and a server. This handshake is intended to provide a secret key to both client and server that will be used to cipher the flow.
In fact a master secret is obtained from the handshake from which the secret key is derived. In OpenSSL this master_secret is kept within the SSL Session SSL_SESSION.
The initial handshake can provide server authentication, client authentication or no authentication at all.
Default usage in HTTPS is to verify server authenticity with trusted Certificate Authorities known by the browser.
A quick presentation for a classical TLS handshake ( RSA, without Session tickets and without client authentication ) under CC BY license http://blog.artisanlogiciel.net/public/tech/classical_handshake.odp feel free to improve it.
Since the handshake uses public key cryptography heavily and this is CPU intensive compared to symmetric ( secret key ) cryptography, the protocol provides ways to reuse existing credentials to reissue new secret keys for new connections ( new TCP connections ) or to renew existing connections.
Browsers use this heavily when connecting to https sites since they open multiple connections to the same site at a time. The first connection does the handshake while all the others use a quick handshake (can be named resumed, abbreviated or restart handshake) allowing saving for both client and server CPU.
RFC 2246, section 7, p. 23
These items are then used to create security parameters for use by the Record Layer when protecting application data. Many connections can be instantiated using the same session through the resumption feature of the TLS Handshake Protocol.
This explains difference the between an OpenSSL SSL Connection ( SSL ) and an SSL Session ( SSL_SESSION ) , each SSL Connection runs on its TCP connection and can share the same SSL Session with other SSL connections.
( to obtain session from connection use function : SSL_SESSION *SSL_get_session(const SSL *ssl) )
On a Ssl connection a renegotiation can occur to request for new cipher suites or key materials.
To renegotiate a Client will send a ClientHello over its existing SSL connection; a Server will send a ServerHello
It created a vulnerability that was addressed by TLS extension to notify server whenever a connection is renegotiating and allows to verify it is legit.
This is RFC5746 "Transport Layer Security (TLS) Renegotiation Indication Extension" http://tools.ietf.org/html/rfc5746 to perform Secure Renegotiation
Server Name Indication
SNI Extension from RFC 3546, Transport Layer Security (TLS) Extensions.
Allows a client to specify at the very beginning of the handshake what server name it wants to connect to.
This is very useful for a web server that serves multiple domains but doesn't have a wildcard certificate or a certificate containing a full list of supported domains.
In this case the server can learn from the client what Certificate the client expects to receive.
This is Public Key Certified by a Certificate with Trust from client. Trust from client can be done automatically with Certificate Authority trust.
It is crucial that clients check the Server Certificate against the expected hostname Hostname_validation
Client authentication is optional. in many cases client does not authenticaiton at ssl layer, but with usage of protocols above ssl by exemple with HTTP authenticate methods.
- Certificate Request ( TLS v1.2 http://tools.ietf.org/html/rfc5246#section-7.4.4 )
Server can send a Certificate Request with digest algorithms and a list CA Distinguished names which will be used by the client to select the Client Certificate it will send.
- Client Certificate ( TLS v1.2 http://tools.ietf.org/html/rfc5246#section-7.4.6)
Client send its Client Certificate first then all intermediate Certificates, if any, up to the CA ( optionally excluded ).
- CertificateVerify ( TLS v1.2 http://tools.ietf.org/html/rfc5246#section-7.4.8 )
The Client sends a Certificate Verify that is signed by the private key counterpart of its Client public key included in the Certificate with digest algorithm over whole handshake messages so far ( excluding this one of course ).
This proves that this client owns the private key that applies to this specific handshake and hence authenticates the client for this session.
Alternate Authentication Methods
Public Key Certificate
This is the most commonly used method. With X509 Certificates and Certficate Authorities.
It applies To Server Certificate or to Client Certificate authentication.
Depending on CipherSuite, for Server Public Key can be used to derive pre-master-key.
TLS PSK Pre Shared Key
TLS SRP : Secure Remote Password. Allows authentication with a password over TLS.
Supported by OpenSSL with version 1.0.1.
TLS SRP is negotiated with various ciphersuites, currently all use SHA to compute SRP.
With SRP trust is based on the fact that both parties should know the password ( or Password Verifier ) to complete the SRP Verify Handshake.
It is possible to use RSA or DSS additionaly to prove Server identity with Certificates.