ssl_certificate_key

The ssl_certificate_key directive specifies the private key file used for SSL/TLS encryption in NGINX.

Syntaxssl_certificate_key path;
Defaultnone
Contexthttp, server
Arguments1

Description

The ssl_certificate_key directive is a critical setting in configuring secure HTTPS connections in NGINX. This directive allows the user to specify the file that contains the private key corresponding to the SSL certificate defined in ssl_certificate directive. It ensures that NGINX can establish secure SSL/TLS sessions by decrypting the data sent by clients and providing a secure layer for transmitting data over the internet.

In practice, the ssl_certificate_key directive takes one argument, which is the path to the private key file. The context in which this directive can be used is within 'http' or 'server' blocks, enabling it to be specified globally or per virtual server. It's important to ensure that the private key file has correct permissions, as it must be accessible by the NGINX process, but should remain secure from unauthorized access to prevent exposure of sensitive information.

Misconfiguration of this directive can lead to SSL handshake failures and errors such as "SSL_CTX_use_PrivateKey_file() failed". Therefore, it is essential to verify that the private key corresponds to the certificate specified and both are properly configured in NGINX's configuration files.

Config Example

server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate /etc/ssl/certs/example.com.crt;
    ssl_certificate_key /etc/ssl/private/example.com.key;
}

The private key must match the associated SSL certificate.

Ensure the NGINX process has read permission on the private key file.

Using a passphrase-protected private key may require additional configuration.

← Back to all directives