大网数据广告活动
服务器运维问答

How to set up a nested if for an exim tls certificate?

· 52CE 我爱测

At first my config for exim tls certificate looked like this: tls_certificate = ${if exists{/etc/exim4/ssl/${tls_sni}.crt}{/etc/exim4/ssl/${tls_sni}.crt}{/etc/exim4/ssl/exim.crt}} tls_privatekey = ${if exists{/etc/exim4/ssl/${tls…

问题原文

原帖链接 · itsme · CC BY-SA 3.0

At first my config for exim tls certificate looked like this:

tls_certificate = ${if exists{/etc/exim4/ssl/${tls_sni}.crt}{/etc/exim4/ssl/${tls_sni}.crt}{/etc/exim4/ssl/exim.crt}}
tls_privatekey = ${if exists{/etc/exim4/ssl/${tls_sni}.key}{/etc/exim4/ssl/${tls_sni}.key}{/etc/exim4/ssl/exim.key}}

And it works.

I'm trying to make a nested condition:

tls_certificate = ${if exists{/etc/exim4/ipssl/${received_ip_address}.crt}{/etc/exim4/ipssl/${received_ip_address}.crt}{${if exists{/etc/exim4/ssl/${tls_sni}.crt}{/etc/exim4/ssl/${tls_sni}.crt}{/etc/exim4/ssl/exim.crt}}}
tls_privatekey = ${if exists{/etc/exim4/ipssl/${received_ip_address}.key}{/etc/exim4/ipssl/${received_ip_address}.key}{${if exists{/etc/exim4/ssl/${tls_sni}.key}{/etc/exim4/ssl/${tls_sni}.key}{/etc/exim4/ssl/exim.key}}}

This config passes the syntactic test (exim -bV), but the server closes tcp-connection immediately after any client connects with the message in paniclog:

2017-08-01 07:14:56 expansion of tls_certificate failed: missing or misplaced { or }

I thought that I can not use nested if conditions, but then I found this in the default exim config:

REMOTE_SMTP_RETURN_PATH=${if match_domain{$sender_address_domain}{+local_domains}{${sender_address_local_part}@DCreadhost}{${if match_domain{$sender_address_domain}{ETC_MAILNAME}{${sender_address_local_part}@DCreadhost}fail}}}

Why are nested conditions not working in my case? Is there a way to make similar conditions for tls certs?

已采纳解答

原帖链接 · markkuit · CC BY-SA 3.0

I believe you're missing one closing bracket. Tip: try writing the condition like this when testing it for easier debugging when issues like this arise:

${
  if exists{/etc/exim4/ipssl/${received_ip_address}.crt} {
    /etc/exim4/ipssl/${received_ip_address}.crt
  } {
    ${
      if exists{/etc/exim4/ssl/${tls_sni}.crt} {
        /etc/exim4/ssl/${tls_sni}.crt
      } {
        /etc/exim4/ssl/exim.crt
      }
    }
  }
} <--

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-08-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。