@@ -101,14 +101,6 @@ static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 12] = [
101101 offset : 0 ,
102102 post : ptr:: null_mut ( ) ,
103103 } ,
104- ngx_command_t {
105- name : ngx_string ! ( "chain" ) ,
106- type_ : NGX_CONF_TAKE1 as ngx_uint_t ,
107- set : Some ( cmd_issuer_set_chain) ,
108- conf : 0 ,
109- offset : 0 ,
110- post : ptr:: null_mut ( ) ,
111- } ,
112104 ngx_command_t {
113105 name : ngx_string ! ( "challenge" ) ,
114106 type_ : NGX_CONF_TAKE1 as ngx_uint_t ,
@@ -133,6 +125,14 @@ static mut NGX_HTTP_ACME_ISSUER_COMMANDS: [ngx_command_t; 12] = [
133125 offset : 0 ,
134126 post : ptr:: null_mut ( ) ,
135127 } ,
128+ ngx_command_t {
129+ name : ngx_string ! ( "preferred_chain" ) ,
130+ type_ : NGX_CONF_TAKE1 as ngx_uint_t ,
131+ set : Some ( cmd_issuer_set_preferred_chain) ,
132+ conf : 0 ,
133+ offset : 0 ,
134+ post : ptr:: null_mut ( ) ,
135+ } ,
136136 ngx_command_t {
137137 name : ngx_string ! ( "profile" ) ,
138138 type_ : nginx_sys:: NGX_CONF_TAKE12 as ngx_uint_t ,
@@ -351,36 +351,6 @@ extern "C" fn cmd_add_certificate(
351351 NGX_CONF_OK
352352}
353353
354- extern "C" fn cmd_issuer_set_chain (
355- cf : * mut ngx_conf_t ,
356- _cmd : * mut ngx_command_t ,
357- conf : * mut c_void ,
358- ) -> * mut c_char {
359- let cf = unsafe { cf. as_mut ( ) . expect ( "cf" ) } ;
360- let issuer = unsafe { conf. cast :: < Issuer > ( ) . as_mut ( ) . expect ( "issuer conf" ) } ;
361-
362- if issuer. chain . is_some ( ) {
363- return NGX_CONF_DUPLICATE ;
364- }
365-
366- for value in & cf. args ( ) [ 1 ..] {
367- // SAFETY: the value is well aligned, and the conversion result is assigned to an object in
368- // the same pool.
369- let Ok ( value) = ( unsafe { conf_value_to_str ( value) } ) else {
370- return NGX_CONF_INVALID_VALUE ;
371- } ;
372-
373- if let Some ( name) = value. strip_prefix ( "issuer=" ) {
374- issuer. chain = Some ( issuer:: CertificateChainMatcher :: new ( name) ) ;
375- continue ;
376- }
377-
378- return NGX_CONF_INVALID_VALUE ;
379- }
380-
381- NGX_CONF_OK
382- }
383-
384354extern "C" fn cmd_issuer_set_challenge (
385355 cf : * mut ngx_conf_t ,
386356 _cmd : * mut ngx_command_t ,
@@ -552,6 +522,32 @@ extern "C" fn cmd_issuer_set_external_account_key(
552522 NGX_CONF_OK
553523}
554524
525+ extern "C" fn cmd_issuer_set_preferred_chain (
526+ cf : * mut ngx_conf_t ,
527+ _cmd : * mut ngx_command_t ,
528+ conf : * mut c_void ,
529+ ) -> * mut c_char {
530+ let cf = unsafe { cf. as_mut ( ) . expect ( "cf" ) } ;
531+ let issuer = unsafe { conf. cast :: < Issuer > ( ) . as_mut ( ) . expect ( "issuer conf" ) } ;
532+
533+ if issuer. chain . is_some ( ) {
534+ return NGX_CONF_DUPLICATE ;
535+ }
536+
537+ // NGX_CONF_TAKE1 ensures that args contains 2 elements
538+ let args = cf. args ( ) ;
539+
540+ // SAFETY: the value is well aligned, and the conversion result is assigned to an object in
541+ // the same pool.
542+ let Ok ( issuer_name) = ( unsafe { conf_value_to_str ( & args[ 1 ] ) } ) else {
543+ return NGX_CONF_INVALID_VALUE ;
544+ } ;
545+
546+ issuer. chain = Some ( issuer:: CertificateChainMatcher :: new ( issuer_name) ) ;
547+
548+ NGX_CONF_OK
549+ }
550+
555551extern "C" fn cmd_issuer_set_profile (
556552 cf : * mut ngx_conf_t ,
557553 _cmd : * mut ngx_command_t ,
0 commit comments