subjectAltNameToString
subjectAltNameToString
Renders one SubjectAltName as text.
| variant | rendering |
|---|---|
dns, ip, email, uri, srv | the value itself |
directoryName | distinguishedNameToString of the embedded name, or the DER hex if it does not decode |
unknown | lowercase hex of the raw content bytes |
ts
function subjectAltNameToString(
name: SubjectAltName,
options?: SubjectAltNameTextOptions,
): stringParameters
name:SubjectAltNameoptions?:SubjectAltNameTextOptions
Examples
Render every SAN of a parsed certificate
ts
const names = (parsed.subjectAltNames ?? []).map((name) => subjectAltNameToString(name));
// ['example.com', '192.0.2.1', 'CN=Example CA,C=US']
subjectAltNameToString({ type: 'dns', value: 'example.com' }, { prefix: true }); // 'DNS:example.com'