'Creates a Name object from a dict of unicode string keys and values.
The keys should be from NameType._map, or a dotted-integer OID unicode
string.
:param name_dict:
A dict of name information, e.g. {"common_name": "Will Bond",
"country_name": "US", "organization": "Codex Non Sufficit LC"}
:param use_printable:
A bool - if PrintableString should be used for encoding instead of
UTF8String. This is for backwards compatiblity with old software.
:return:
An x509.Name object'

@classmethod
def build(cls, name_dict, use_printable=False):

    rdns = []
    if (not use_printable):
        encoding_name = u'utf8_string'
        encoding_class = UTF8String
    else:
        encoding_name = u'printable_string'
        encoding_class = PrintableString
    name_dict = OrderedDict(sorted(name_dict.items(), key=(lambda item: NameType.preferred_ordinal(item[0]))))
    for (attribute_name, attribute_value) in name_dict.items():
        attribute_name = NameType.map(attribute_name)
        if (attribute_name == u'email_address'):
            value = EmailAddress(attribute_value)
        elif (attribute_name == u'domain_component'):
            value = DNSName(attribute_value)
        elif (attribute_name in set([u'dn_qualifier', u'country_name', u'serial_number'])):
            value = DirectoryString(name=u'printable_string', value=PrintableString(attribute_value))
        else:
            value = DirectoryString(name=encoding_name, value=encoding_class(attribute_value))
        rdns.append(RelativeDistinguishedName([NameTypeAndValue({u'type': attribute_name, u'value': value})]))
    return cls(name=u'', value=RDNSequence(rdns))
