lighttpd - 根据在 ssl 协商期间发现的客户端证书 CN 的值拒绝连接。 (ssl.verifyclient)

lighttpd - reject a connection based on the value of the client cert CN discovered during ssl negotiation. (ssl.verifyclient)

我想根据在 ssl 协商期间发现的客户端证书 CN 的值来丢弃或拒绝连接。 我不熟悉语法,找不到类似的例子。

我受困于 lighttpd v.1.4.45

真实代码和伪代码的混合:

$SERVER["socket"] == ":443" {
  ssl.engine = "enable"
  ...
  ssl.ca-file =  "..."
  ...
  # client side authentification       
  ssl.verifyclient.activate = "enable"
  ssl.verifyclient.enforce = "enable"
  ssl.verifyclient.depth = "2"
  # this line instructs client cert CN value to be extracted
  ssl.verifyclient.username = "SSL_CLIENT_S_DN_CN"  
}
# psuedocode
<client CN> <not regexp-equal> <regexp> {
  <reject>
}

能做到lighttpd级别吗?假设向下查看应用程序代码不是一个选项。

(我也很想看看如何在应用程序级别完成的示例,但这不是主要问题。)

使用 lighttpd mod_auth。 https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModAuth

server.modules += ("mod_auth")
auth.require = ( "" =>
                 (
                   "method"  => "extern",
                   "realm"   => "certificate",
                   "require" => "user=agent007|user=agent008" 
                 )
               )

您必须在 user=...|user=...

中列出允许的 SSL_CLIENT_S_DN_CN 值