I'm running into a strange issue when setting a component using pyasn1. I construct and empty certificate and put a certificate to be signed in it:
empty = rfc2459.Certificate()
empty['tbsCertificate'] = rfc2459.TBSCertificate()
Now I want to set a version, which fails with an actual version object, but works by automatically creating a type:
empty['tbsCertificate']['version'] = rfc2459.Version('v3')
# PyAsn1Error: Component type error Version('v1') vs Version('v3')
empty['tbsCertificate']['version'] = 'v3'
# works
Which is strange given those two compare equal:
empty['tbsCertificate']['version'] == rfc2459.Version('v3')
# True
So why doesn't the first way work?