Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在Python中解码的SSL证书中包含元组?_Python_Ssl_Ssl Certificate - Fatal编程技术网

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

为什么在Python中解码的SSL证书中包含元组?,python,ssl,ssl-certificate,Python,Ssl,Ssl Certificate,这是的输出示例,取自文档 {'issuer': ((('countryName', 'IL'),), (('organizationName', 'StartCom Ltd.'),), (('organizationalUnitName', 'Secure Digital Certificate Signing'),), (('commonName', 'StartCo

这是的输出示例,取自文档

{'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}

我想知道issuer和subject中的单元素元组的用途是什么。主题是否可以在同一行中具有多个属性?

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

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

AttributeTypeAndValue ::= SEQUENCE {
    type     AttributeType,
    value    AttributeValue }
嗯,也许不是

例如,我想可能会遇到一个属性类型局部性的多个实例,但可能性不大。根据用例的不同,我会忽略相同类型的后续值,并记录一条警告以帮助调试

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

默认的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
下面是Python中激活第二个o的结果:


我还是不明白。即使有两个localityName属性,它们也会像“主题”一样:“localityName”、“马德里”、“localityName”、“巴黎”?@ntrrgc:是的。但老实说,这有什么关系呢?好吧,我试着理解API。我可以在cert['subject']]中为x执行subject=[x[0]。他们应该使用元组的元组而不是元组的元组,这是有原因的。@ntrgc:shoulda,woulda,coulda。x、 500是复杂的,充满了原油…没有理由去假设原因。我希望我创建了一个证书来解决这个问题。表面上看,是的,一些字段可以有多个条目。例如,您可以有多个通用名称。我怀疑,为了简化解析,它们将所有键值对视为可能具有多个字段,以避免对每个数据类型进行定制检查?请参阅@hop-answer。即使在这种情况下,它们似乎也是1元组行。
{'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'),))}