我很好奇为什么某些 Web 服务器(例如 Nginx)以相反的顺序提供客户端 SSL DN。
Web 应用程序将 DN 发布到 Java Web 服务,该服务尝试创建 Javajavax.naming.ldap.LdapName http://docs.oracle.com/javase/7/docs/api/javax/naming/ldap/LdapName.html?is-external=true.
标准订单(LDAP 或 X500Name):
"CN=Jimmy Blooptoop,OU=Someplace,OU=Employees,DC=Bloopsoft-Inc"
逆序(OpenSSL 单行格式)(Nginx 返回为 _$ssl_client_s_dn _):
"/DC=Bloopsoft-Inc/OU=Employees/OU=Someplace/CN=Jimmy Blooptoop"
为什么是这样?
哪一项符合 LDAP RFC?
他们两个都这样吗?
LDAP RFC 注释:
有许多与 LDAP 相关的 RFC:https://www.ldap.com/ldap-specifications-define-in-rfcs https://www.ldap.com/ldap-specifications-defined-in-rfcs
许多人引用了不同的内容,以下是对它们的快速历史的尝试:
July 1993: RFC 1485 - A String Representation of Distinguished Names
March 1995: RFC 1779 - A String Representation of Distinguished Names
- 1997 年 12 月:RFC 2253 - 轻量级目录访问协议 (v3):可分辨名称的 UTF-8 字符串表示形式
- 2002 年 9 月:RFC 3377 - 轻量级目录访问协议 (v3):技术规范(更新 RFC 2253)
March 2003: RFC 3494 - Lightweight Directory Access Protocol version 2 (LDAPv2) to Historic Status (Retiring RFC 1485, RFC 1779)
-
2006 年 6 月:RFC 4514- 轻量级目录访问协议 (LDAP):可分辨名称的字符串表示形式
最近的一个,它取代了其他的:RFC 4514:轻量级目录访问协议 (LDAP):可分辨名称的字符串表示形式 https://docs.ldap.com/specs/rfc4514.txt
Java 库:
是否有一个Java库可以来回转换(从反向到不反向)? LdapName 抛出 InvalidNameException。看起来应该有,倒退格式经常出现。
Java 库:
-
javax.naming.ldap.LdapName https://docs.oracle.com/javase/7/docs/api/javax/naming/ldap/LdapName.html支持 RFC 2253
-
org.apache.directory.api.ldap.model.filter.FilterEncoder https://directory.apache.org/api/gen-docs/latest/apidocs/org/apache/directory/api/ldap/model/filter/FilterEncoder.html支持 RFC 4514
-
Spring LdapUtils http://docs.spring.io/spring-ldap/docs/current/apidocs/org/springframework/ldap/support/LdapUtils.html包裹 LdapName
- 关于使用 BouncyCastle X509Name 解析和压缩 DN 的文章:http://www.sivachandran.in/2012/11/comparing-x509-distinguished-name-with.html http://www.sivachandran.in/2012/11/comparing-x509-distinguished-name-with.html
Nginx 注释:
- http://nginx.org/en/docs/http/ngx_http_ssl_module.html http://nginx.org/en/docs/http/ngx_http_ssl_module.html
链接:
- 如何在Java中从X509Certificate中提取CN? https://stackoverflow.com/questions/2914521/how-to-extract-cn-from-x509certificate-in-java
-
从证书 DN 中解析 CN https://stackoverflow.com/questions/7933468/parsing-the-cn-out-of-a-certificate-dn(借用 DN 示例)
- Nginx 信息 http://nategood.com/client-side-certificate-authentication-in-ngi
- X500主要杰出姓名顺序 https://stackoverflow.com/questions/10871922/x500principal-distinguished-name-order
- https://wiki.nikhef.nl/grid/How_to_handle_OpenSSL_and_not_get_hurt_background_information https://wiki.nikhef.nl/grid/How_to_handle_OpenSSL_and_not_get_hurt_background_information
- https://www.openssl.org/docs/manmaster/apps/x509.html#item_oneline https://www.openssl.org/docs/manmaster/apps/x509.html#item_oneline