
in the current popularity of HTTPS, SSL handshake as the pre-link of encrypted communication, its efficiency directly affects the loading speed and user experience of the website. Many operation and maintenance personnel found that frequent SSL handshake will increase server load, slow down page response, and even cause user churn. This article will share the performance improvement methods of SSL handshake from the perspectives of protocol selection, session reuse, hardware optimization, etc., to help practitioners solve the performance bottleneck of encrypted communication.
SSL handshake depends largely on the protocol version used, and the handshake process complexity and efficiency of different protocols vary significantly.
1, priority to enable TLS 1.3 protocol
TLS 1.3 is the most advanced encryption protocol at present. Compared with the old version of TLS 1.2, it reduces the number of round trips of SSL handshake from 2 to 1, and even implements 0-RTT handshake in session reuse scenarios. At the same time, TLS 1.3 removes a large number of old and inefficient encryption algorithms, and only retains the algorithm suite that takes into account security and performance, which greatly reduces the computational overhead of SSL handshake. Operators can configure servers such as Nginx and Apache to set TLS 1.3 as the priority protocol, and at the same time be compatible with TLS 1.2 to cover the old version client side.
2 Disable outdated SSL protocol versions
SSL 2.0, SSL 3.0 and other outdated protocols not only have serious security bugs, but also their SSL handshake process is extremely cumbersome and computational efficiency is extremely low. Disabling these protocols not only improves security, but also avoids the server from consuming unnecessary resources for the outdated client side. At present, mainstream browsers no longer support these old protocols. Operations personnel can directly close relevant options in the server configuration to reduce invalid SSL handshake requests.
SSL handshake lies in key negotiation and certificate verification. Session reuse technology can skip part of the handshake process by reusing the previous session information and greatly shorten the handshake time.
1 Enable session ID reuse mechanism
session ID is the unique identifier assigned to the client by the server during the SSL handshake. When the client side connects again, it can carry this ID to request a multiplexing session. After the server verifies the validity of the ID, it can directly use the previously negotiated key, skip the certificate exchange and key calculation steps, and reduce the SSL handshake time to about 30% of the original. The operation and maintenance personnel can set the timeout time of the session ID in the server configuration. It is recommended to set it to 300 seconds to 900 seconds to balance the multiplexing efficiency with the server memory occupation.
2, configure session ticket reuse function
session ticket is a stateless session reuse method. The server encrypts the session information and sends it to the client side for storage. When the client side connects again, it can complete the SSL handshake with the ticket. Compared with the session ID, the session ticket does not need the server to store the session information, which can reduce the server memory consumption and is more suitable for the distributed cluster environment. When configuring, make sure to use a strong encryption key to encrypt the ticket to avoid the leakage of session information.
SSL handshake process involves a lot of encryption operations, selecting efficient encryption algorithms and hardware acceleration schemes can significantly reduce the CPU load of the server.
1, choose a lightweight encryption algorithm suite
different encryption algorithm suites have obvious differences in the amount of calculation during SSL handshake, the ECC elliptic curve encryption algorithm suite is preferred, which is only about 10% of the RSA algorithm, and the key length is shorter under the same security strength, which can greatly reduce the time of SSL handshake. For example, in the TLS 1.3 protocol, efficient suites such as TLS_AES_256_GCM_SHA384 and TLS_CHACHA20_POLY1305_SHA256 can be configured to improve the efficiency of SSL handshake while ensuring security.
2 Enable hardware encryption acceleration
most modern server CPUs have built-in AES-NI encryption Instruction Set Architecture, which can hardware accelerate the encryption operations during the SSL handshake process, reducing CPU usage by more than 40%. Operators can enable AES-NI support in the server system and enable hardware acceleration options in the web server configuration. For high concurrency scenarios, a dedicated SSL offload device can also be deployed to transfer the encryption operations of the SSL handshake from the web server to a dedicated device, further improving overall performance.
in addition to protocol and algorithm level optimization, caching related SSL handshake information can also effectively reduce the overhead of repeated handshakes.
1, configure OCSP Stapling cache
OCSP Stapling allows the server to obtain the revocation status information of the certificate in advance and send it to the client side during the SSL handshake, which avoids the client side from inquiring the certificate authority alone and reduces the additional requests for the SSL handshake. The operation and maintenance personnel can configure the server to regularly cache OCSP response information and set a reasonable cache expiration time, which not only ensures the timeliness of the information, but also avoids frequent queries to the certificate authority.
2, optimize client side caching strategy
guide the client side to cache the session information and certificate chain related to the SSL handshake, which can reduce the number of SSL handshakes during repeated connections. For example, set reasonable cache control parameters in the server response header to let the client side store the session ID and ticket for a long time, and ensure that the cache time of the certificate chain matches the valid period of the certificate to avoid the client side repeatedly downloading the certificate chain.
To sum up, the performance optimization of SSL handshake is a multi-dimensional project, which needs to be started from multiple levels such as protocol selection, session reuse, algorithm hardware, and cache strategy. By enabling the TLS 1.3 protocol, configuring the session reuse mechanism, selecting lightweight encryption algorithms, and enabling hardware acceleration, it can effectively reduce the SSL handshake delay, reduce the server load, and ultimately improve the response speed and user experience of HTTPS websites. Operation and maintenance personnel can choose the appropriate optimization plan according to their own server environment and business needs and gradually implement it.