从NGINX中的客户端证书的专有名称中获取通用名称

编程入门 行业动态 更新时间:2024-10-24 06:24:24
本文介绍了从NGINX中的客户端证书的专有名称中获取通用名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要在NGINX中获得客户端证书的CN,以将其附加到代理标头中.

I need to get the CN of a client certificate in NGINX to append it to the proxy headers.

我已经为此找到了以下地图代码.

I already found the following map code for this.

map $ssl_client_s_dn $ssl_client_s_dn_cn { default ""; ~/CN=(?<CN>[^/]+) $CN; }

但是可悲的是,它只为以下$ ssl_client_s_dn返回一个空字符串:CN = testcn,O =测试组织

But sadly it only returns an empty string for the following $ssl_client_s_dn: CN=testcn,O=Test Organization

我也用其他DN测试了它.但是问题总是一样.

I tested it with other DNs, too. But the problem is always the same.

推荐答案

您使用的模式需要旧版DN,因为它假定/来分隔RDN.因此(自nginx v1.11.6起)可以进行以下工作:

The pattern you use requires the legacy DN, since it assumes the / to separate the RDNs. So (since nginx v1.11.6) the following works:

map $ssl_client_s_dn_legacy $ssl_client_s_dn_cn { default ""; ~/CN=(?<CN>[^/]+) $CN; }

使用$ ssl_client_s_dn_legacy:/O =测试组织/CN = testcn

With $ssl_client_s_dn_legacy: /O=Test Organization/CN=testcn

更多推荐

从NGINX中的客户端证书的专有名称中获取通用名称

本文发布于:2023-10-23 01:59:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519406.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:名称   客户端   证书   NGINX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!