Kim*_*ais 5 openssl m2crypto x509
一点点背景:我正在使用M2Crypto和Django 构建一个证书颁发机构,所以请在投票前三思而后行关闭主题!:)
我的方法是通过电子邮件地址识别最终用户,并且他们的自签名信任锚显然是由他们自己发布的,但我应该如何存储他们的"身份"?
我已经在野外看到了许多证书,其中的做法是将邮件地址存储为subjectAltName = rfc822:user@domain.test,但谷歌搜索建议标准方式subjectAltName = email:user@domain.test.
两者之间有什么区别,如果是的话,哪一个更受欢迎?
两者之间是否有任何区别,如果有的话,哪个是更可取的?
并不是的; 这取决于您使用的PKI配置文件。PKI和X509是狂野西部。
如果您在组织内部运行私有PKI,则无关紧要。挑选一些东西,并坚持下去
在网络上,其通常为PKIX,并在RFC 5280,Internet X.509公钥基础结构证书和证书吊销列表(CRL)配置文件中指定。根据4.1.2.6,主题:
Conforming implementations generating new certificates with
electronic mail addresses MUST use the rfc822Name in the subject
alternative name extension (Section 4.2.1.6) to describe such
identities. Simultaneous inclusion of the emailAddress attribute in
the subject distinguished name to support legacy implementations is
deprecated but permitted.
Run Code Online (Sandbox Code Playgroud)
然后是第4.2.1.6节,使用者备用名称:
When the subjectAltName extension contains an Internet mail address,
the address MUST be stored in the rfc822Name. The format of an
rfc822Name is a "Mailbox" as defined in Section 4.1.2 of [RFC2821].
A Mailbox has the form "Local-part@Domain". Note that a Mailbox has
no phrase (such as a common name) before it, has no comment (text
surrounded in parentheses) after it, and is not surrounded by "<" and
">".
Run Code Online (Sandbox Code Playgroud)
请注意,它不使用rfc822:user@domain.test或email:user@domain.test。就像我说的,它是荒野的西部。您应该为任何事情做好准备。
您还拥有CA /浏览器论坛及其颁发证书的标准。感兴趣的两个文件是:
但是,它们回溯到RFC 5280。
您所看到的rfc822:和email:可能是由软件添加的,用于演示。例如,要枚举使用OpenSSL的SAN,您的函数应类似于:
void print_san_name(X509* const cert)
{
int success = 0;
GENERAL_NAMES* names = NULL;
unsigned char* utf8 = NULL;
do
{
if(!cert) break; /* failed */
names = X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0 );
if(!names) break;
int i = 0, count = sk_GENERAL_NAME_num(names);
if(!count) break; /* failed */
for( i = 0; i < count; ++i )
{
GENERAL_NAME* entry = sk_GENERAL_NAME_value(names, i);
if(!entry) continue;
if(GEN_DNS == entry->type)
{
int len1 = 0, len2 = -1;
len1 = ASN1_STRING_to_UTF8(&utf8, entry->d.dNSName);
if(utf8) {
len2 = (int)strlen((const char*)utf8);
}
if(len1 != len2) {
fprintf(stderr, "Strlen and ASN1_STRING size do not match (embedded null?):"
" %d vs %d\n", len2, len1);
/* Handle error */
}
/* Do something with utf8 */
if(utf8) {
OPENSSL_free(utf8), utf8 = NULL;
}
}
else if(GEN_EMAIL == entry->type)
{
...
}
...
}
} while (0);
if(names)
GENERAL_NAMES_free(names);
if(utf8)
OPENSSL_free(utf8);
}
Run Code Online (Sandbox Code Playgroud)
(对不起,我没有提取IA5Strings方便的示例)。
在上面,请注意类型:GEN_DNS或常规DNS名称。该名称用于www.example.com。OpenSSL有其中一些类型,以下是来自x509v3.h:
#define GEN_OTHERNAME 0
#define GEN_EMAIL 1
#define GEN_DNS 2
#define GEN_X400 3
#define GEN_DIRNAME 4
#define GEN_EDIPARTY 5
#define GEN_URI 6
#define GEN_IPADD 7
#define GEN_RID 8
Run Code Online (Sandbox Code Playgroud)
您的证书查看器或演示软件可能正在显示,rfc822:或者email:因为遇到类型而显示GEN_EMAIL。
查看OpenSSL的配置文件时,您将看到例如:
...
[ v3_ca ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer:always
subjectAltName = email:myEmail@email.com
issuerAltName = issuer:copy
Run Code Online (Sandbox Code Playgroud)
该email:是没有原始拷贝到SAN。相反,它告诉OpenSSL使用GEN_EMAIL该字段的类型。
如果您的证书查看器或演示软件未添加前缀,则可能是解析专有名称。
至于专有名称,彼得·古特曼(Peter Gutmann)很久以前告诉我(摘自他的电子邮件):“在DN中粘贴您想要的任何内容,只显示有用的位”。就像我说的,它是荒野的西部。
电子邮件地址也可能显示在OID下。例如,1.2.840.113549.1.9.1 arc。这是对SAN的补充。这就是为什么下图带有该标签“ Email Address”的原因。
Peter Gutmann有一个X509样式指南。从他的描述中获取:它描述了各种X.509证书实现细节和陷阱,提供了有关做什么和不做什么的建议,并以列出了现有实现中需要注意的已知错误和问题为结尾。
最后,这是Startcom颁发的用户证书。他们提供免费证书,并在需要时向您收取吊销费用(因为这就是费用所在)。这与其他CA完全相反,其他CA负责对撤销进行预先收费,如果不需要的话,将其收入囊中;)
第一个是X509证书:

其次是使用Gutmann的证书转储dumpasn1(从www.cs.auckland.ac.nz/~pgut001获取dumpasn1.c和dumpasn1.cfg;使用gcc dumpasn1.c -o dumpasn1; 编译并复制到中/usr/local/bin)。注意没有rfc822:或email:前缀:

| 归档时间: |
|
| 查看次数: |
6057 次 |
| 最近记录: |