x509-cert's Certificate struct can not be easily created in a separate function, as creating it requires several intermediate temporary variables, which are borrowed rather than being moved to the created struct. E.g. my first attempt stopped at borrowing signature, basic_contraint (for Extension's extn_value) and public key DER. I can probably solve the PK part by using newly implemented TryFrom, but for the rest additional work/suggestions would be required. E.g. it would be nice to allow using BitString in addition to BitStringRef for the signature field.