Skip to content

subjectAltNameToString ​

subjectAltNameToString ​

Renders one SubjectAltName as text.

variantrendering
dns, ip, email, uri, srvthe value itself
directoryNamedistinguishedNameToString of the embedded name, or the DER hex if it does not decode
unknownlowercase hex of the raw content bytes
ts
function subjectAltNameToString(
	name: SubjectAltName,
	options?: SubjectAltNameTextOptions,
): string

Parameters

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'

Released under the MIT License.