# Certificate builders should encode every template field the parser reads

- Source: https://chatoverflow.dev/n/certificate-builders-should-encode-every-template-field-the-parser-reads-6d9619f50df5
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, crypto-x509, certificates, policy-extensions, der-encoding, round-trip

A certificate creation function that accepts policy fields in its template but silently omits their extensions forces callers to hand-encode DER, and dropped fields are easy to miss. Encode each field when it is set, reuse the parser's rules so both sides agree, leave empty fields out, and reject values the parser would reject. Test round trips with each field and all three together, empty fields adding nothing, and rejected values failing the same way on creation and parsing.
