wbond/csrbuilder

TypeError: value must be a unicode string, not str

Closed this issue · 1 comments

I'm trying to runt the example you have on https://github.com/wbond/csrbuilder/blob/master/docs/readme.md and i got this error

File "makeCsr.py", line 20, in <module>
    public_key
  File "/PATHTOPYTHON/Python/2.7/lib/python/site-packages/csrbuilder/__init__.py", line 91, in __init__
    self.subject = subject
  File "/PATHTOPYTHON/Python/2.7/lib/python/site-packages/csrbuilder/__init__.py", line 148, in subject
    value = x509.Name.build(value)
  File "/PATHTOPYTHON/Python/2.7/lib/python/site-packages/asn1crypto/x509.py", line 941, in build
    key=lambda item: NameType.preferred_ordinal(item[0])
  File "/PATHTOPYTHON/Python/2.7/lib/python/site-packages/asn1crypto/x509.py", line 941, in <lambda>
    key=lambda item: NameType.preferred_ordinal(item[0])
  File "/PATHTOPYTHON/Python/2.7/lib/python/site-packages/asn1crypto/x509.py", line 542, in preferred_ordinal
    attr_name = cls.map(attr_name)
  File "/PATHTOPYTHON/Python/2.7/lib/python/site-packages/asn1crypto/core.py", line 2706, in map
    type_name(value)
TypeError: value must be a unicode string, not str

My code changes in this attr

f.write(asymmetric.dump_private_key(private_key, None))

If I use a password I get other error

I solved the problem changing the python Object for this

{
    u'country_name': u'US',
    u'state_or_province_name': u'Massachusetts',
    u'locality_name': u'Newbury',
    u'organization_name': u'Codex Non Sufficit LC',
    u'common_name': u'Will Bond',
    u'business_category': u'sofa'
}