loading ssl_certificate from a variable

daveb nginx-forum at forum.nginx.org
Wed Jun 23 13:29:46 UTC 2021


I'm trying to load the cert/key from a variable, based on the documentation


Using this configuration:

 server {
        listen       19099 ssl;

        set $mycert "-----BEGIN CERTIFICATE----- ...";
        set $mypkey "-----BEGIN PRIVATE KEY----- ...";
        ssl_certificate "data:$mycert";  
        ssl_certificate_key "data:$mypkey";


When I connect to port 19099, nginx reports this error (v 1.19.7)

[error] 16408#0: *1 cannot load certificate "data:": PEM_read_bio_X509_AUX()
failed (SSL: error:0909006C:PEM routines:get_name:no start line:Expecting:
TRUSTED CERTIFICATE) while SSL handshaking, client:, server:

I realize that this might not be a great idea, but I don't understand why
it's not working. Can someone please explain what's wrong with the config? 


Posted at Nginx Forum: https://forum.nginx.org/read.php?2,291902,291902#msg-291902

More information about the nginx mailing list