Forum Discussion

GeorgeShuklin's avatar
GeorgeShuklin
Icon for Nimbostratus rankNimbostratus
Aug 26, 2024

How to store a certificate in the configuration file?

Documentation for ngx_http_ssl_module says that it's possible to store the certificate (and the key) in variables.

The value data:$variable can be specified instead of the file (1.15.10), which loads a certificate from a variable without using intermediate files. Note that inappropriate use of this syntax may have its security implications, such as writing secret key data to error log.

Which is implying it's possible to store the certificate value in the variable. I'm trying to guess how to do it and can't find the proper way.

 

I've tried:

set $ssl_cert "-----BEGIN CERTIFICATE-----
MIIDHDCCAgQC
...
-----END CERTIFICATE-----
";

and

set $ssl_cert "application/x-pem-file;-----BEGIN CERTIFICATE-----
MIIDHDCCAgQC
...
-----END CERTIFICATE-----
";

 

Both didn't worked. What is the syntax for storing PEM file in the variable?