当前位置: 首页>>代码示例>>Python>>正文


Python x509.RelativeDistinguishedName方法代码示例

本文整理汇总了Python中cryptography.x509.RelativeDistinguishedName方法的典型用法代码示例。如果您正苦于以下问题:Python x509.RelativeDistinguishedName方法的具体用法?Python x509.RelativeDistinguishedName怎么用?Python x509.RelativeDistinguishedName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cryptography.x509的用法示例。


在下文中一共展示了x509.RelativeDistinguishedName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _decode_x509_name

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def _decode_x509_name(backend, x509_name):
    count = backend._lib.X509_NAME_entry_count(x509_name)
    attributes = []
    prev_set_id = -1
    for x in range(count):
        entry = backend._lib.X509_NAME_get_entry(x509_name, x)
        attribute = _decode_x509_name_entry(backend, entry)
        set_id = backend._lib.Cryptography_X509_NAME_ENTRY_set(entry)
        if set_id != prev_set_id:
            attributes.append(set([attribute]))
        else:
            # is in the same RDN a previous entry
            attributes[-1].add(attribute)
        prev_set_id = set_id

    return x509.Name(x509.RelativeDistinguishedName(rdn) for rdn in attributes) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:decode_asn1.py

示例2: _decode_x509_name

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def _decode_x509_name(backend, x509_name):
    count = backend._lib.X509_NAME_entry_count(x509_name)
    attributes = []
    prev_set_id = -1
    for x in range(count):
        entry = backend._lib.X509_NAME_get_entry(x509_name, x)
        attribute = _decode_x509_name_entry(backend, entry)
        set_id = backend._lib.Cryptography_X509_NAME_ENTRY_set(entry)
        if set_id != prev_set_id:
            attributes.append({attribute})
        else:
            # is in the same RDN a previous entry
            attributes[-1].add(attribute)
        prev_set_id = set_id

    return x509.Name(x509.RelativeDistinguishedName(rdn) for rdn in attributes) 
开发者ID:tp4a,项目名称:teleport,代码行数:18,代码来源:decode_asn1.py

示例3: format_relative_name

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def format_relative_name(name):
    """Convert a relative name (RDN) into a canonical form.

    Examples::

        >>> format_relative_name([('C', 'AT'), ('CN', 'example.com')])
        '/C=AT/CN=example.com'
        >>> format_relative_name(x509.RelativeDistinguishedName([
        ...     x509.NameAttribute(NameOID.COMMON_NAME, u'example.com')
        ... ]))
        '/CN=example.com'
    """
    if isinstance(name, x509.RelativeDistinguishedName):
        name = [(OID_NAME_MAPPINGS[s.oid], s.value) for s in name]

    return '/%s' % ('/'.join(['%s=%s' % (force_text(k), force_text(v)) for k, v in name])) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:18,代码来源:utils.py

示例4: x509_relative_name

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def x509_relative_name(name):
    """Parse a relative name (RDN) into a :py:class:`~cg:cryptography.x509.RelativeDistinguishedName`.

    >>> x509_relative_name('/CN=example.com')
    <RelativeDistinguishedName(CN=example.com)>
    >>> x509_relative_name([('CN', 'example.com')])
    <RelativeDistinguishedName(CN=example.com)>
    """
    if isinstance(name, x509.RelativeDistinguishedName):
        return name
    elif isinstance(name, str):
        name = parse_name(name)

    return x509.RelativeDistinguishedName([
        x509.NameAttribute(NAME_OID_MAPPINGS[typ], force_text(value)) for typ, value in name
    ]) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:18,代码来源:utils.py

示例5: _decode_distpoint

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def _decode_distpoint(backend, distpoint):
    if distpoint.type == _DISTPOINT_TYPE_FULLNAME:
        full_name = _decode_general_names(backend, distpoint.name.fullname)
        return full_name, None

    # OpenSSL code doesn't test for a specific type for
    # relativename, everything that isn't fullname is considered
    # relativename.  Per RFC 5280:
    #
    # DistributionPointName ::= CHOICE {
    #      fullName                [0]      GeneralNames,
    #      nameRelativeToCRLIssuer [1]      RelativeDistinguishedName }
    rns = distpoint.name.relativename
    rnum = backend._lib.sk_X509_NAME_ENTRY_num(rns)
    attributes = set()
    for i in range(rnum):
        rn = backend._lib.sk_X509_NAME_ENTRY_value(
            rns, i
        )
        backend.openssl_assert(rn != backend._ffi.NULL)
        attributes.add(
            _decode_x509_name_entry(backend, rn)
        )

    relative_name = x509.RelativeDistinguishedName(attributes)

    return None, relative_name 
开发者ID:tp4a,项目名称:teleport,代码行数:29,代码来源:decode_asn1.py

示例6: test_format

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def test_format(self):
        rdn = x509.RelativeDistinguishedName([x509.NameAttribute(NameOID.COMMON_NAME, u'example.com')])
        self.assertEqual(format_relative_name([('C', 'AT'), ('CN', 'example.com')]), '/C=AT/CN=example.com')
        self.assertEqual(format_relative_name(rdn), '/CN=example.com') 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:6,代码来源:tests_utils.py

示例7: test_parse

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def test_parse(self):
        expected = x509.RelativeDistinguishedName([x509.NameAttribute(NameOID.COMMON_NAME, u'example.com')])
        self.assertEqual(x509_relative_name('/CN=example.com'), expected)
        self.assertEqual(x509_relative_name([('CN', 'example.com')]), expected) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:6,代码来源:tests_utils.py

示例8: rdn

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import RelativeDistinguishedName [as 别名]
def rdn(r):  # just a shortcut
    return x509.RelativeDistinguishedName([x509.NameAttribute(*t) for t in r]) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:4,代码来源:base.py


注:本文中的cryptography.x509.RelativeDistinguishedName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。