Path: blob/main/xml/en/docs/stream/ngx_stream_ssl_module.xml
1 views
<?xml version="1.0"?>12<!--3Copyright (C) Nginx, Inc.4-->56<!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">78<module name="Module ngx_stream_ssl_module"9link="/en/docs/stream/ngx_stream_ssl_module.html"10lang="en"11rev="47">1213<section id="summary">1415<para>16The <literal>ngx_stream_ssl_module</literal> module (1.9.0)17provides the necessary support for a stream proxy server to work with18the SSL/TLS protocol.19</para>2021<para>22This module is not built by default, it should be enabled with the23<literal>--with-stream_ssl_module</literal>24configuration parameter.25<note>26This module requires the27<link url="http://www.openssl.org">OpenSSL</link> library.28</note>29</para>3031</section>323334<section id="example" name="Example Configuration">3536<para>37To reduce the processor load, it is recommended to38<list type="bullet">3940<listitem>41set the number of42<link doc="../ngx_core_module.xml" id="worker_processes">worker processes</link>43equal to the number of processors,44</listitem>4546<listitem>47enable the <link id="ssl_session_cache_shared">shared</link> session cache,48</listitem>4950<listitem>51disable the <link id="ssl_session_cache_builtin">built-in</link> session cache,52</listitem>5354<listitem>55and possibly increase the session <link id="ssl_session_timeout">lifetime</link>56(by default, 5 minutes):57</listitem>5859</list>6061<example>62<emphasis>worker_processes auto;</emphasis>6364stream {6566...6768server {69listen 12345 ssl;7071ssl_protocols TLSv1.2 TLSv1.3;72ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;73ssl_certificate /usr/local/nginx/conf/cert.pem;74ssl_certificate_key /usr/local/nginx/conf/cert.key;75<emphasis>ssl_session_cache shared:SSL:10m;</emphasis>76<emphasis>ssl_session_timeout 10m;</emphasis>7778...79}80</example>81</para>8283</section>848586<section id="directives" name="Directives">8788<directive name="ssl_alpn">89<syntax><value>protocol</value> ...</syntax>90<default/>91<context>stream</context>92<context>server</context>93<appeared-in>1.21.4</appeared-in>9495<para>96Specifies the list of supported97<link url="https://datatracker.ietf.org/doc/html/rfc7301">ALPN</link> protocols.98One of the protocols must be99<link id="var_ssl_alpn_protocol">negotiated</link> if the client uses ALPN:100<example>101map $ssl_alpn_protocol $proxy {102h2 127.0.0.1:8001;103http/1.1 127.0.0.1:8002;104}105106server {107listen 12346;108proxy_pass $proxy;109ssl_alpn h2 http/1.1;110}111</example>112</para>113114</directive>115116117<directive name="ssl_certificate">118<syntax><value>file</value></syntax>119<default/>120<context>stream</context>121<context>server</context>122123<para>124Specifies a <value>file</value> with the certificate in the PEM format125for the given virtual server.126If intermediate certificates should be specified in addition to a primary127certificate, they should be specified in the same file in the following128order: the primary certificate comes first, then the intermediate certificates.129A secret key in the PEM format may be placed in the same file.130</para>131132<para>133Since version 1.11.0,134this directive can be specified multiple times135to load certificates of different types, for example, RSA and ECDSA:136<example>137server {138listen 12345 ssl;139140ssl_certificate example.com.rsa.crt;141ssl_certificate_key example.com.rsa.key;142143ssl_certificate example.com.ecdsa.crt;144ssl_certificate_key example.com.ecdsa.key;145146...147}148</example>149<note>150Only OpenSSL 1.0.2 or higher supports separate151<link doc="../http/configuring_https_servers.xml" id="chains">certificate152chains</link>153for different certificates.154With older versions, only one certificate chain can be used.155</note>156</para>157158<para id="ssl_certificate_variables">159Since version 1.15.9, variables can be used in the <value>file</value> name160when using OpenSSL 1.0.2 or higher:161<example>162ssl_certificate $ssl_server_name.crt;163ssl_certificate_key $ssl_server_name.key;164</example>165Note that using variables implies that166a certificate will be loaded for each SSL handshake,167and this may have a negative impact on performance.168</para>169170<para id="ssl_certificate_data">171The value172<literal>data</literal>:<value>$variable</value>173can be specified instead of the <value>file</value> (1.15.10),174which loads a certificate from a variable175without using intermediate files.176Note that inappropriate use of this syntax may have its security implications,177such as writing secret key data to178<link doc="../ngx_core_module.xml" id="error_log">error log</link>.179</para>180181<para>182It should be kept in mind that due to the SSL/TLS protocol limitations,183for maximum interoperability with clients that do not use184<link url="http://en.wikipedia.org/wiki/Server_Name_Indication">SNI</link>,185virtual servers with different certificates should listen on186<link doc="../http/configuring_https_servers.xml"187id="name_based_https_servers">different188IP addresses</link>.189</para>190191</directive>192193194<directive name="ssl_certificate_cache">195<syntax><literal>off</literal></syntax>196<syntax>197<literal>max</literal>=<value>N</value>198[<literal>inactive</literal>=<value>time</value>]199[<literal>valid</literal>=<value>time</value>]</syntax>200<default>off</default>201<context>stream</context>202<context>server</context>203<appeared-in>1.27.4</appeared-in>204205<para>206Defines a cache that stores207<link id="ssl_certificate">SSL certificates</link> and208<link id="ssl_certificate_key">secret keys</link>209specified with <link id="ssl_certificate_key_variables">variables</link>.210</para>211212<para>213The directive has the following parameters:214<list type="tag">215216<tag-name id="ssl_certificate_cache_max">217<literal>max</literal>218</tag-name>219<tag-desc>220sets the maximum number of elements in the cache;221on cache overflow the least recently used (LRU) elements are removed;222</tag-desc>223224<tag-name id="ssl_certificate_cache_inactive">225<literal>inactive</literal>226</tag-name>227<tag-desc>228defines a time after which an element is removed from the cache229if it has not been accessed during this time;230by default, it is 10 seconds;231</tag-desc>232233<tag-name id="ssl_certificate_cache_valid">234<literal>valid</literal>235</tag-name>236<tag-desc>237defines a time during which238an element in the cache is considered valid239and can be reused;240by default, it is 60 seconds.241Certificates that exceed this time will be reloaded or revalidated;242</tag-desc>243244<tag-name id="ssl_certificate_cache_off">245<literal>off</literal>246</tag-name>247<tag-desc>248disables the cache.249</tag-desc>250251</list>252</para>253254<para>255Example:256<example>257ssl_certificate $ssl_server_name.crt;258ssl_certificate_key $ssl_server_name.key;259ssl_certificate_cache max=1000 inactive=20s valid=1m;260</example>261</para>262263</directive>264265266<directive name="ssl_certificate_compression">267<syntax><literal>on</literal> | <literal>off</literal></syntax>268<default>off</default>269<context>stream</context>270<context>server</context>271<appeared-in>1.29.1</appeared-in>272273<para>274Enables TLS 1.3275<link url="https://datatracker.ietf.org/doc/html/rfc8879">compression</link>276of server certificates.277<note>278The directive is supported when using OpenSSL 3.2 or higher;279the list of supported compression algorithms is provided by the library.280</note>281<note>282The directive is supported when using BoringSSL;283the list of supported compression algorithms includes284<literal>zlib</literal> (1.29.3).285</note>286</para>287288</directive>289290291<directive name="ssl_certificate_key">292<syntax><value>file</value></syntax>293<default/>294<context>stream</context>295<context>server</context>296297<para>298Specifies a <value>file</value> with the secret key in the PEM format299for the given virtual server.300</para>301302<para>303The value304<literal>engine</literal>:<value>name</value>:<value>id</value>305can be specified instead of the <value>file</value>,306which loads a secret key with a specified <value>id</value>307from the OpenSSL engine <value>name</value>.308</para>309310<para>311The value312<literal>store</literal>:<value>scheme</value>:<value>id</value>313can be specified instead of the <value>file</value> (1.29.0),314which is used to load a secret key with a specified <value>id</value>315and OpenSSL provider registered URI <value>scheme</value>, such as316<link url="https://datatracker.ietf.org/doc/html/rfc7512"><literal>pkcs11</literal></link>.317</para>318319<para id="ssl_certificate_key_data">320The value321<literal>data</literal>:<value>$variable</value>322can be specified instead of the <value>file</value> (1.15.10),323which loads a secret key from a variable without using intermediate files.324Note that inappropriate use of this syntax may have its security implications,325such as writing secret key data to326<link doc="../ngx_core_module.xml" id="error_log">error log</link>.327</para>328329<para id="ssl_certificate_key_variables">330Since version 1.15.9, variables can be used in the <value>file</value> name331when using OpenSSL 1.0.2 or higher.332</para>333334</directive>335336337<directive name="ssl_ciphers">338<syntax><value>ciphers</value></syntax>339<default>HIGH:!aNULL:!MD5</default>340<context>stream</context>341<context>server</context>342343<para>344Specifies the enabled ciphers.345The ciphers are specified in the format understood by the346OpenSSL library, for example:347<example>348ssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;349</example>350</para>351352<para>353The full list can be viewed using the354“<command>openssl ciphers</command>” command.355</para>356357</directive>358359360<directive name="ssl_client_certificate">361<syntax><value>file</value></syntax>362<default/>363<context>stream</context>364<context>server</context>365<appeared-in>1.11.8</appeared-in>366367<para>368Specifies a <value>file</value> with trusted CA certificates in the PEM format369used to <link id="ssl_verify_client">verify</link> client certificates and370OCSP responses if <link id="ssl_stapling"/> is enabled.371</para>372373<para>374The list of certificates will be sent to clients.375If this is not desired, the <link id="ssl_trusted_certificate"/>376directive can be used.377</para>378379</directive>380381382<directive name="ssl_conf_command">383<syntax><value>name</value> <value>value</value></syntax>384<default/>385<context>stream</context>386<context>server</context>387<appeared-in>1.19.4</appeared-in>388389<para>390Sets arbitrary OpenSSL configuration391<link url="https://www.openssl.org/docs/man1.1.1/man3/SSL_CONF_cmd.html">commands</link>.392<note>393The directive is supported when using OpenSSL 1.0.2 or higher.394</note>395</para>396397<para>398Several <literal>ssl_conf_command</literal> directives399can be specified on the same level:400<example>401ssl_conf_command Options PrioritizeChaCha;402ssl_conf_command Ciphersuites TLS_CHACHA20_POLY1305_SHA256;403</example>404These directives are inherited from the previous configuration level405if and only if there are no <literal>ssl_conf_command</literal> directives406defined on the current level.407</para>408409<para>410<note>411Note that configuring OpenSSL directly412might result in unexpected behavior.413</note>414</para>415416</directive>417418419<directive name="ssl_crl">420<syntax><value>file</value></syntax>421<default/>422<context>stream</context>423<context>server</context>424<appeared-in>1.11.8</appeared-in>425426<para>427Specifies a <value>file</value> with revoked certificates (CRL)428in the PEM format used to <link id="ssl_verify_client">verify</link>429client certificates.430When using intermediate certificates, their CRLs should be431specified in the same file.432</para>433434</directive>435436437<directive name="ssl_dhparam">438<syntax><value>file</value></syntax>439<default/>440<context>stream</context>441<context>server</context>442443<para>444Specifies a <value>file</value> with DH parameters for DHE ciphers.445</para>446447<para>448By default no parameters are set,449and therefore DHE ciphers will not be used.450<note>451Prior to version 1.11.0, builtin parameters were used by default.452</note>453</para>454455</directive>456457458<directive name="ssl_ecdh_curve">459<syntax><value>curve</value></syntax>460<default>auto</default>461<context>stream</context>462<context>server</context>463464<para>465Specifies a <value>curve</value> for ECDHE ciphers.466</para>467468<para>469When using OpenSSL 1.0.2 or higher,470it is possible to specify multiple curves (1.11.0), for example:471<example>472ssl_ecdh_curve prime256v1:secp384r1;473</example>474</para>475476<para>477The special value <literal>auto</literal> (1.11.0) instructs nginx to use478a list built into the OpenSSL library when using OpenSSL 1.0.2 or higher,479or <literal>prime256v1</literal> with older versions.480</para>481482<para>483<note>484Prior to version 1.11.0,485the <literal>prime256v1</literal> curve was used by default.486</note>487</para>488489<para>490<note>491When using OpenSSL 1.0.2 or higher,492this directive sets the list of curves supported by the server.493Thus, in order for ECDSA certificates to work,494it is important to include the curves used in the certificates.495</note>496</para>497498</directive>499500501<directive name="ssl_ech_file">502<syntax><value>file</value></syntax>503<default/>504<context>stream</context>505<context>server</context>506<appeared-in>1.29.4</appeared-in>507508<para>509Specifies a <value>file</value> with encrypted ClientHello configuration510(<literal>ECHConfig</literal>) in the511<link url="https://datatracker.ietf.org/doc/draft-farrell-tls-pemesni/">PEM</link>512format used to enable TLS 1.3513<link url="https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni">ECH</link>514in shared mode.515</para>516517<para>518<note>519The directive is currently supported only when using OpenSSL520<link url="https://github.com/openssl/openssl/tree/feature/ech">ECH521feature branch</link>.522</note>523</para>524525</directive>526527528<directive name="ssl_handshake_timeout">529<syntax><value>time</value></syntax>530<default>60s</default>531<context>stream</context>532<context>server</context>533534<para>535Specifies a timeout for the SSL handshake to complete.536</para>537538</directive>539540541<directive name="ssl_key_log">542<syntax>path</syntax>543<default/>544<context>stream</context>545<context>server</context>546<appeared-in>1.27.2</appeared-in>547548<para>549Enables logging of client connection SSL keys550and specifies the path to the key log file.551Keys are logged in the552<link url="https://datatracker.ietf.org/doc/html/draft-ietf-tls-keylogfile">SSLKEYLOGFILE</link>553format compatible with Wireshark.554</para>555556<para>557<note>558This directive is available as part of our559<commercial_version>commercial subscription</commercial_version>.560</note>561</para>562563</directive>564565566<directive name="ssl_ocsp">567<syntax><literal>on</literal> |568<literal>off</literal> |569<literal>leaf</literal></syntax>570<default>off</default>571<context>stream</context>572<context>server</context>573<appeared-in>1.27.2</appeared-in>574575<para>576Enables OCSP validation of the client certificate chain.577The <literal>leaf</literal> parameter578enables validation of the client certificate only.579</para>580581<para>582For the OCSP validation to work,583the <link id="ssl_verify_client"/> directive should be set to584<literal>on</literal> or <literal>optional</literal>.585</para>586587<para>588To resolve the OCSP responder hostname,589the <link doc="ngx_stream_core_module.xml" id="resolver"/> directive590should also be specified.591</para>592593<para>594Example:595<example>596ssl_verify_client on;597ssl_ocsp on;598resolver 192.0.2.1;599</example>600</para>601602</directive>603604605<directive name="ssl_ocsp_cache">606<syntax>607<literal>off</literal> |608[<literal>shared</literal>:<value>name</value>:<value>size</value>]</syntax>609<default>off</default>610<context>stream</context>611<context>server</context>612<appeared-in>1.27.2</appeared-in>613614<para>615Sets <literal>name</literal> and <literal>size</literal> of the cache616that stores client certificates status for OCSP validation.617The cache is shared between all worker processes.618A cache with the same name can be used in several619virtual servers.620</para>621622<para>623The <literal>off</literal> parameter prohibits the use of the cache.624</para>625626</directive>627628629<directive name="ssl_ocsp_responder">630<syntax><value>url</value></syntax>631<default/>632<context>stream</context>633<context>server</context>634<appeared-in>1.27.2</appeared-in>635636<para>637Overrides the URL of the OCSP responder specified in the638“<link url="https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.2.1">Authority639Information Access</link>” certificate extension640for <link id="ssl_ocsp">validation</link> of client certificates.641</para>642643<para>644Only “<literal>http://</literal>” OCSP responders are supported:645<example>646ssl_ocsp_responder http://ocsp.example.com/;647</example>648</para>649650</directive>651652653<directive name="ssl_password_file">654<syntax><value>file</value></syntax>655<default/>656<context>stream</context>657<context>server</context>658659<para>660Specifies a <value>file</value> with passphrases for661<link id="ssl_certificate_key">secret keys</link>662where each passphrase is specified on a separate line.663Passphrases are tried in turn when loading the key.664</para>665666<para>667Example:668<example>669stream {670ssl_password_file /etc/keys/global.pass;671...672673server {674listen 127.0.0.1:12345;675ssl_certificate_key /etc/keys/first.key;676}677678server {679listen 127.0.0.1:12346;680681# named pipe can also be used instead of a file682ssl_password_file /etc/keys/fifo;683ssl_certificate_key /etc/keys/second.key;684}685}686</example>687</para>688689</directive>690691692<directive name="ssl_prefer_server_ciphers">693<syntax><literal>on</literal> | <literal>off</literal></syntax>694<default>off</default>695<context>stream</context>696<context>server</context>697698<para>699Specifies that server ciphers should be preferred over client ciphers700when the SSLv3 and TLS protocols are used.701</para>702703</directive>704705706<directive name="ssl_protocols">707<syntax>708[<literal>SSLv2</literal>]709[<literal>SSLv3</literal>]710[<literal>TLSv1</literal>]711[<literal>TLSv1.1</literal>]712[<literal>TLSv1.2</literal>]713[<literal>TLSv1.3</literal>]</syntax>714<default>TLSv1.2 TLSv1.3</default>715<context>stream</context>716<context>server</context>717718<para>719Enables the specified protocols.720</para>721722<para>723If the directive is specified724on the <link doc="ngx_stream_core_module.xml" id="server"/> level,725the value from the default server can be used.726Details are provided in the727“<link doc="../http/server_names.xml" id="virtual_server_selection">Virtual728server selection</link>” section.729</para>730731<para>732<note>733The <literal>TLSv1.1</literal> and <literal>TLSv1.2</literal> parameters734work only when OpenSSL 1.0.1 or higher is used.735</note>736<note>737The <literal>TLSv1.3</literal> parameter (1.13.0) works only when738OpenSSL 1.1.1 or higher is used.739</note>740<note>741The <literal>TLSv1.3</literal> parameter is used by default742since 1.23.4.743</note>744</para>745746</directive>747748749<directive name="ssl_reject_handshake">750<syntax><literal>on</literal> | <literal>off</literal></syntax>751<default>off</default>752<context>stream</context>753<context>server</context>754<appeared-in>1.25.5</appeared-in>755756<para>757If enabled, SSL handshakes in758the <link doc="ngx_stream_core_module.xml" id="server"/> block will be rejected.759</para>760761<para>762For example, in the following configuration, SSL handshakes with763server names other than <literal>example.com</literal> are rejected:764<example>765server {766listen 443 ssl default_server;767ssl_reject_handshake on;768}769770server {771listen 443 ssl;772server_name example.com;773ssl_certificate example.com.crt;774ssl_certificate_key example.com.key;775}776</example>777</para>778779</directive>780781782<directive name="ssl_session_cache">783<syntax>784<literal>off</literal> |785<literal>none</literal> |786[<literal>builtin</literal>[:<value>size</value>]]787[<literal>shared</literal>:<value>name</value>:<value>size</value>]</syntax>788<default>none</default>789<context>stream</context>790<context>server</context>791792<para>793Sets the types and sizes of caches that store session parameters.794A cache can be of any of the following types:795<list type="tag">796797<tag-name><literal>off</literal></tag-name>798<tag-desc>799the use of a session cache is strictly prohibited:800nginx explicitly tells a client that sessions may not be reused.801</tag-desc>802803<tag-name><literal>none</literal></tag-name>804<tag-desc>805the use of a session cache is gently disallowed:806nginx tells a client that sessions may be reused, but does not807actually store session parameters in the cache.808</tag-desc>809810<tag-name id="ssl_session_cache_builtin"><literal>builtin</literal></tag-name>811<tag-desc>812a cache built in OpenSSL; used by one worker process only.813The cache size is specified in sessions.814If size is not given, it is equal to 20480 sessions.815Use of the built-in cache can cause memory fragmentation.816</tag-desc>817818<tag-name id="ssl_session_cache_shared"><literal>shared</literal></tag-name>819<tag-desc>820a cache shared between all worker processes.821The cache size is specified in bytes; one megabyte can store822about 4000 sessions.823Each shared cache should have an arbitrary name.824A cache with the same name can be used in several825virtual servers.826It is also used to automatically generate, store, and827periodically rotate TLS session ticket keys (1.23.2)828unless configured explicitly829using the <link id="ssl_session_ticket_key"/> directive.830</tag-desc>831832</list>833</para>834835<para>836Both cache types can be used simultaneously, for example:837<example>838ssl_session_cache builtin:1000 shared:SSL:10m;839</example>840but using only shared cache without the built-in cache should841be more efficient.842</para>843844</directive>845846847<directive name="ssl_session_ticket_key">848<syntax><value>file</value></syntax>849<default/>850<context>stream</context>851<context>server</context>852853<para>854Sets a <value>file</value> with the secret key used to encrypt855and decrypt TLS session tickets.856The directive is necessary if the same key has to be shared between857multiple servers.858By default, a randomly generated key is used.859</para>860861<para>862If several keys are specified, only the first key is863used to encrypt TLS session tickets.864This allows configuring key rotation, for example:865<example>866ssl_session_ticket_key current.key;867ssl_session_ticket_key previous.key;868</example>869</para>870871<para>872The <value>file</value> must contain 80 or 48 bytes873of random data and can be created using the following command:874<example>875openssl rand 80 > ticket.key876</example>877Depending on the file size either AES256 (for 80-byte keys, 1.11.8)878or AES128 (for 48-byte keys) is used for encryption.879</para>880881</directive>882883884<directive name="ssl_session_tickets">885<syntax><literal>on</literal> | <literal>off</literal></syntax>886<default>on</default>887<context>stream</context>888<context>server</context>889890<para>891Enables or disables session resumption through892<link url="https://datatracker.ietf.org/doc/html/rfc5077">TLS session tickets</link>.893</para>894895</directive>896897898<directive name="ssl_session_timeout">899<syntax><value>time</value></syntax>900<default>5m</default>901<context>stream</context>902<context>server</context>903904<para>905Specifies a time during which a client may reuse the906session parameters.907</para>908909</directive>910911912<directive name="ssl_stapling">913<syntax><literal>on</literal> | <literal>off</literal></syntax>914<default>off</default>915<context>stream</context>916<context>server</context>917<appeared-in>1.27.2</appeared-in>918919<para>920Enables or disables921<link url="https://datatracker.ietf.org/doc/html/rfc6066#section-8">stapling922of OCSP responses</link> by the server.923Example:924<example>925ssl_stapling on;926resolver 192.0.2.1;927</example>928</para>929930<para>931For the OCSP stapling to work, the certificate of the server certificate932issuer should be known.933If the <link id="ssl_certificate"/> file does934not contain intermediate certificates,935the certificate of the server certificate issuer should be936present in the937<link id="ssl_trusted_certificate"/> file.938</para>939940<para>941For a resolution of the OCSP responder hostname,942the <link doc="ngx_stream_core_module.xml" id="resolver"/> directive943should also be specified.944</para>945946</directive>947948949<directive name="ssl_stapling_file">950<syntax><value>file</value></syntax>951<default/>952<context>stream</context>953<context>server</context>954<appeared-in>1.27.2</appeared-in>955956<para>957When set, the stapled OCSP response will be taken from the958specified <value>file</value> instead of querying959the OCSP responder specified in the server certificate.960</para>961962<para>963The file should be in the DER format as produced by the964“<literal>openssl ocsp</literal>” command.965</para>966967</directive>968969970<directive name="ssl_stapling_responder">971<syntax><value>url</value></syntax>972<default/>973<context>stream</context>974<context>server</context>975<appeared-in>1.27.2</appeared-in>976977<para>978Overrides the URL of the OCSP responder specified in the979“<link url="https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.2.1">Authority980Information Access</link>” certificate extension.981</para>982983<para>984Only “<literal>http://</literal>” OCSP responders are supported:985<example>986ssl_stapling_responder http://ocsp.example.com/;987</example>988</para>989990</directive>991992993<directive name="ssl_stapling_verify">994<syntax><literal>on</literal> | <literal>off</literal></syntax>995<default>off</default>996<context>stream</context>997<context>server</context>998<appeared-in>1.27.2</appeared-in>9991000<para>1001Enables or disables verification of OCSP responses by the server.1002</para>10031004<para>1005For verification to work, the certificate of the server certificate1006issuer, the root certificate, and all intermediate certificates1007should be configured as trusted using the1008<link id="ssl_trusted_certificate"/> directive.1009</para>10101011</directive>101210131014<directive name="ssl_trusted_certificate">1015<syntax><value>file</value></syntax>1016<default/>1017<context>stream</context>1018<context>server</context>1019<appeared-in>1.11.8</appeared-in>10201021<para>1022Specifies a <value>file</value> with trusted CA certificates in the PEM format1023used to <link id="ssl_verify_client">verify</link> client certificates and1024OCSP responses if <link id="ssl_stapling"/> is enabled.1025</para>10261027<para>1028In contrast to the certificate set by <link id="ssl_client_certificate"/>,1029the list of these certificates will not be sent to clients.1030</para>10311032</directive>103310341035<directive name="ssl_verify_client">1036<syntax>1037<literal>on</literal> | <literal>off</literal> |1038<literal>optional</literal> | <literal>optional_no_ca</literal></syntax>1039<default>off</default>1040<context>stream</context>1041<context>server</context>1042<appeared-in>1.11.8</appeared-in>10431044<para>1045Enables verification of client certificates.1046The verification result is stored in the1047<link id="var_ssl_client_verify">$ssl_client_verify</link> variable.1048If an error has occurred during the client certificate verification1049or a client has not presented the required certificate,1050the connection is closed.1051</para>10521053<para>1054The <literal>optional</literal> parameter requests the client1055certificate and verifies it if the certificate is present.1056</para>10571058<para>1059The <literal>optional_no_ca</literal> parameter1060requests the client1061certificate but does not require it to be signed by a trusted CA certificate.1062This is intended for the use in cases when a service that is external to nginx1063performs the actual certificate verification.1064The contents of the certificate is accessible through the1065<link id="var_ssl_client_cert">$ssl_client_cert</link> variable.1066</para>10671068</directive>106910701071<directive name="ssl_verify_depth">1072<syntax><value>number</value></syntax>1073<default>1</default>1074<context>stream</context>1075<context>server</context>1076<appeared-in>1.11.8</appeared-in>10771078<para>1079Sets the verification depth in the client certificates chain.1080</para>10811082</directive>10831084</section>108510861087<section id="variables" name="Embedded Variables">10881089<para>1090The <literal>ngx_stream_ssl_module</literal> module supports variables1091since 1.11.2.1092<list type="tag">10931094<tag-name id="var_ssl_alpn_protocol"><var>$ssl_alpn_protocol</var></tag-name>1095<tag-desc>1096returns the protocol selected by ALPN during the SSL handshake,1097or an empty string otherwise (1.21.4);1098</tag-desc>10991100<tag-name id="var_ssl_cipher"><var>$ssl_cipher</var></tag-name>1101<tag-desc>1102returns the name of the cipher used1103for an established SSL connection;1104</tag-desc>11051106<tag-name id="var_ssl_ciphers"><var>$ssl_ciphers</var></tag-name>1107<tag-desc>1108returns the list of ciphers supported by the client (1.11.7).1109Known ciphers are listed by names, unknown are shown in hexadecimal,1110for example:1111<example>1112AES128-SHA:AES256-SHA:0x00ff1113</example>1114<note>1115The variable is fully supported only when using OpenSSL version 1.0.2 or higher.1116With older versions, the variable is available1117only for new sessions and lists only known ciphers.1118</note>1119</tag-desc>11201121<tag-name id="var_ssl_client_cert"><var>$ssl_client_cert</var></tag-name>1122<tag-desc>1123returns the client certificate in the PEM format1124for an established SSL connection, with each line except the first1125prepended with the tab character (1.11.8);1126</tag-desc>11271128<tag-name id="var_ssl_client_fingerprint"><var>$ssl_client_fingerprint</var></tag-name>1129<tag-desc>1130returns the SHA1 fingerprint of the client certificate1131for an established SSL connection (1.11.8);1132</tag-desc>11331134<tag-name id="var_ssl_client_i_dn"><var>$ssl_client_i_dn</var></tag-name>1135<tag-desc>1136returns the “issuer DN” string of the client certificate1137for an established SSL connection according to1138<link url="https://datatracker.ietf.org/doc/html/rfc2253">RFC 2253</link> (1.11.8);1139</tag-desc>11401141<tag-name id="var_ssl_client_raw_cert"><var>$ssl_client_raw_cert</var>1142</tag-name>1143<tag-desc>1144returns the client certificate in the PEM format1145for an established SSL connection (1.11.8);1146</tag-desc>11471148<tag-name id="var_ssl_client_s_dn"><var>$ssl_client_s_dn</var></tag-name>1149<tag-desc>1150returns the “subject DN” string of the client certificate1151for an established SSL connection according to1152<link url="https://datatracker.ietf.org/doc/html/rfc2253">RFC 2253</link> (1.11.8);1153</tag-desc>11541155<tag-name id="var_ssl_client_serial"><var>$ssl_client_serial</var></tag-name>1156<tag-desc>1157returns the serial number of the client certificate1158for an established SSL connection (1.11.8);1159</tag-desc>11601161<tag-name id="var_ssl_client_sigalg"><var>$ssl_client_sigalg</var></tag-name>1162<tag-desc>1163returns the1164<link url="https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-16">signature algorithm</link>1165for the client certificate for an established SSL connection (1.29.3).1166<note>1167The variable is supported only when using OpenSSL version 3.5 or higher.1168With older versions, the variable value will be an empty string.1169</note>1170<note>1171The variable is available only for new sessions.1172</note>1173</tag-desc>11741175<tag-name id="var_ssl_client_v_end"><var>$ssl_client_v_end</var></tag-name>1176<tag-desc>1177returns the end date of the client certificate (1.11.8);1178</tag-desc>11791180<tag-name id="var_ssl_client_v_remain"><var>$ssl_client_v_remain</var></tag-name>1181<tag-desc>1182returns the number of days1183until the client certificate expires (1.11.8);1184</tag-desc>11851186<tag-name id="var_ssl_client_v_start"><var>$ssl_client_v_start</var></tag-name>1187<tag-desc>1188returns the start date of the client certificate (1.11.8);1189</tag-desc>11901191<tag-name id="var_ssl_client_verify"><var>$ssl_client_verify</var></tag-name>1192<tag-desc>1193returns the result of client certificate verification (1.11.8):1194“<literal>SUCCESS</literal>”, “<literal>FAILED:</literal><value>reason</value>”,1195and “<literal>NONE</literal>” if a certificate was not present;1196</tag-desc>11971198<tag-name id="var_ssl_curve"><var>$ssl_curve</var></tag-name>1199<tag-desc>1200returns the negotiated curve used for1201SSL handshake key exchange process (1.21.5).1202Known curves are listed by names, unknown are shown in hexadecimal,1203for example:1204<example>1205prime256v11206</example>1207<note>1208The variable is supported only when using OpenSSL version 3.0 or higher.1209With older versions, the variable value will be an empty string.1210</note>1211</tag-desc>12121213<tag-name id="var_ssl_curves"><var>$ssl_curves</var></tag-name>1214<tag-desc>1215returns the list of curves supported by the client (1.11.7).1216Known curves are listed by names, unknown are shown in hexadecimal,1217for example:1218<example>12190x001d:prime256v1:secp521r1:secp384r11220</example>1221<note>1222The variable is supported only when using OpenSSL version 1.0.2 or higher.1223With older versions, the variable value will be an empty string.1224</note>1225<note>1226The variable is available only for new sessions.1227</note>1228</tag-desc>12291230<tag-name id="var_ssl_ech_outer_server_name"><var>$ssl_ech_outer_server_name</var></tag-name>1231<tag-desc>1232returns the public server name requested through1233<link url="http://en.wikipedia.org/wiki/Server_Name_Indication">SNI</link>1234if TLS 1.3 <link id="ssl_ech_file">ECH</link> was accepted,1235otherwise “” (1.29.4);1236</tag-desc>12371238<tag-name id="var_ssl_ech_status"><var>$ssl_ech_status</var></tag-name>1239<tag-desc>1240returns the result of TLS 1.3 <link id="ssl_ech_file">ECH</link> processing:1241“<literal>FAILED</literal>”,1242“<literal>BACKEND</literal>”,1243“<literal>GREASE</literal>”,1244“<literal>SUCCESS</literal>”, or1245“<literal>NOT_TRIED</literal>” (1.29.4);1246<note>1247The variable is currently supported only when using OpenSSL1248<link url="https://github.com/openssl/openssl/tree/feature/ech">ECH feature branch</link>1249and is therefore subject to change.1250The variable value will otherwise be an empty string.1251</note>1252</tag-desc>12531254<tag-name id="var_ssl_protocol"><var>$ssl_protocol</var></tag-name>1255<tag-desc>1256returns the protocol of an established SSL connection;1257</tag-desc>12581259<tag-name id="var_ssl_server_name"><var>$ssl_server_name</var></tag-name>1260<tag-desc>1261returns the server name requested through1262<link url="http://en.wikipedia.org/wiki/Server_Name_Indication">SNI</link>;1263</tag-desc>12641265<tag-name id="var_ssl_session_id"><var>$ssl_session_id</var></tag-name>1266<tag-desc>1267returns the session identifier of an established SSL connection;1268</tag-desc>12691270<tag-name id="var_ssl_session_reused"><var>$ssl_session_reused</var></tag-name>1271<tag-desc>1272returns “<literal>r</literal>” if an SSL session was reused,1273or “<literal>.</literal>” otherwise.1274</tag-desc>12751276<tag-name id="var_ssl_sigalg"><var>$ssl_sigalg</var></tag-name>1277<tag-desc>1278returns the1279<link url="https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-16">signature algorithm</link>1280for the server certificate for an established SSL connection (1.29.3).1281<note>1282The variable is supported only when using OpenSSL version 3.5 or higher.1283With older versions, the variable value will be an empty string.1284</note>1285<note>1286The variable is available only for new sessions.1287</note>1288</tag-desc>12891290</list>1291</para>12921293</section>12941295</module>129612971298