code: function getSubjectCommonName(pem) {
  	const hex = X509.pemToHex(pem);
  	const d = ASN1HEX.getDecendantHexTLVByNthList(hex, 0, [0, 5]);
  	const subject = X509.hex2dn(d); // format: '/C=US/ST=California/L=San Francisco/CN=Admin@org1.example.com/emailAddress=admin@org1.example.com'
  	const m = subject.match(/CN=.+[^/]/);
  	if (!m) {
  		throw new Error('Certificate PEM does not seem to contain a valid subject with common name "CN"');
  	} else {
  		return m[0].substring(3);
  	}
  }
docs: This utility is based on jsrsasign.X509.getSubjectString() implementation we can not use that method directly because it requires calling readCertPEM() first which as of jsrsasign@6.2.3 always assumes RSA based certificates and fails to parse certs that includes ECDSA keys.