partial version of type_to_cert (earlier commit wasn't complete)