@@ -49,6 +49,9 @@ local str_find = string.find
4949local str_byte = string.byte
5050local str_sub = string.sub
5151local str_format = string.format
52+ local string = string
53+ local table = table
54+
5255
5356local _M = {}
5457
@@ -502,17 +505,34 @@ Please modify "admin_key" in conf/config.yaml .
502505
503506
504507 if yaml_conf .apisix .ssl .ssl_trusted_certificate ~= nil then
505- local cert_path = yaml_conf .apisix .ssl .ssl_trusted_certificate
506- -- During validation, the path is relative to PWD
507- -- When Nginx starts, the path is relative to conf
508- -- Therefore we need to check the absolute version instead
509- cert_path = pl_path .abspath (cert_path )
508+ local cert_paths = {}
509+ local ssl_certificates = yaml_conf .apisix .ssl .ssl_trusted_certificate
510+ for cert_path in string.gmatch (ssl_certificates , ' ([^,]+)' ) do
511+ cert_path = util .trim (cert_path )
512+ if cert_path == " system" then
513+ local trusted_certs_path , err = util .get_system_trusted_certs_filepath ()
514+ if not trusted_certs_path then
515+ util .die (err )
516+ end
517+ table.insert (cert_paths , trusted_certs_path )
518+ else
519+ -- During validation, the path is relative to PWD
520+ -- When Nginx starts, the path is relative to conf
521+ -- Therefore we need to check the absolute version instead
522+ cert_path = pl_path .abspath (cert_path )
523+ if not pl_path .exists (cert_path ) then
524+ util .die (" certificate path" , cert_path , " doesn't exist\n " )
525+ end
510526
511- if not pl_path . exists ( cert_path ) then
512- util . die ( " certificate path " , cert_path , " doesn't exist \n " )
527+ table.insert ( cert_paths , cert_path )
528+ end
513529 end
514530
515- yaml_conf .apisix .ssl .ssl_trusted_certificate = cert_path
531+ local combined_cert_filepath = yaml_conf .apisix .ssl .ssl_trusted_combined_path
532+ or " /usr/local/apisix/conf/ssl_trusted_combined.pem"
533+ util .gen_trusted_certs_combined_file (combined_cert_filepath , cert_paths )
534+
535+ yaml_conf .apisix .ssl .ssl_trusted_certificate = combined_cert_filepath
516536 end
517537
518538 -- enable ssl with place holder crt&key
0 commit comments