Example #1
0
def Name(cn = None, c = None, o = None):
  names = asn1.SEQUENCE([])

  if cn is not None:
    names.children.append(
      asn1.SET([
        asn1.SEQUENCE([
          COMMON_NAME, cn,
        ])
      ])
    )

  if c is not None:
    names.children.append(
      asn1.SET([
        asn1.SEQUENCE([
          COUNTRY, c,
        ])
      ])
    )

  if o is not None:
    names.children.append(
      asn1.SET([
        asn1.SEQUENCE([
          ORGANIZATION, o,
        ])
      ])
    )

  return names
Example #2
0
def Name(cn):
  return asn1.SEQUENCE([
    asn1.SET([
      asn1.SEQUENCE([
        COMMON_NAME, cn,
      ])
    ])
  ])
Example #3
0
def Name(cn, utf8_cn=False):
  # This module historically used PrintableString for most strings, so maintain
  # that default.
  if utf8_cn:
    cn_encoded = asn1.UTF8String(cn.encode('utf-8'))
  else:
    cn_encoded = asn1.PrintableString(cn.encode('ascii'))
  return asn1.SEQUENCE([asn1.SET([asn1.SEQUENCE([
      COMMON_NAME,
      cn_encoded,
  ])])])