gpt4 book ai didi

python - 为什么在 Python 中将元组包含在解码的 SSL 证书中?

转载 作者:太空宇宙 更新时间:2023-11-03 13:41:02 26 4
gpt4 key购买 nike

这是 ssl.SSLSocket.getpeercert 的示例输出,取自文档。

{'issuer': ((('countryName', 'IL'),),
(('organizationName', 'StartCom Ltd.'),),
(('organizationalUnitName',
'Secure Digital Certificate Signing'),),
(('commonName',
'StartCom Class 2 Primary Intermediate Server CA'),)),
'notAfter': 'Nov 22 08:15:19 2013 GMT',
'notBefore': 'Nov 21 03:09:52 2011 GMT',
'serialNumber': '95F0',
'subject': ((('description', '571208-SLe257oHY9fVQ07Z'),),
(('countryName', 'US'),),
(('stateOrProvinceName', 'California'),),
(('localityName', 'San Francisco'),),
(('organizationName', 'Electronic Frontier Foundation, Inc.'),),
(('commonName', '*.eff.org'),),
(('emailAddress', 'hostmaster@eff.org'),)),
'subjectAltName': (('DNS', '*.eff.org'), ('DNS', 'eff.org')),
'version': 3}

我想知道 issuersubject 中的单元素元组的目的是什么。一个主题可以在同一行中有多个属性吗?

最佳答案

嵌套结构可能直接来自RFC 5280 , 第 4.1.2.4 节:

RelativeDistinguishedName ::=
SET SIZE (1..MAX) OF AttributeTypeAndValue

AttributeTypeAndValue ::= SEQUENCE {
type AttributeType,
value AttributeValue }

嗯,也许不是。

我想可能会遇到一种属性类型(例如 locality)的多个实例,但可能性很小。根据用例,我会忽略相同类型的后续值并记录警告以帮助调试。

如果您认为它值得您花时间,您可以在 X.500 标准中阅读所有相关内容,但对于它的值(value),以下是它的实际行为:

默认的 openssl.cnf 包含这个:

[ req_distinguished_name ]
0.organizationName = Organization Name (eg, company)
0.organizationName_default = Internet Widgits Pty Ltd

# we can do this but it is not needed normally :-)
#1.organizationName = Second Organization Name (eg, company)
#1.organizationName_default = World Wide Web Pty Ltd

如果激活第二个 o,Python 中的结果如下:

{'notAfter': 'Apr 27 20:03:12 2014 GMT',
'subject': ((('countryName', u'AU'),),
(('stateOrProvinceName', u'Some-State'),),
(('organizationName', u'Internet Widgits Pty Ltd'),),
(('organizationName', u'World Wide Web Pty Ltd'),),
(('commonName', u'www.example.com'),),
(('emailAddress', u'foo@example.com'),))}

关于python - 为什么在 Python 中将元组包含在解码的 SSL 证书中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22721025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com