{"id":3537,"date":"2016-03-31T03:18:48","date_gmt":"2016-03-31T03:18:48","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3537"},"modified":"2016-03-31T03:18:48","modified_gmt":"2016-03-31T03:18:48","slug":"parsing-issuerdn-subjectdn-ssl-x-509-certificate","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/parsing-issuerdn-subjectdn-ssl-x-509-certificate\/","title":{"rendered":"Parsing the issuerDN \/ subjectDN in an SSL (X.509) certificate in Scala"},"content":{"rendered":"<pre lang=\"scala\">\ncert.getIssuerDN.getName\ncert.getIssuerDN\n<\/pre>\n<p>You&#8217;ll get values like this:<\/p>\n<pre>\nCN = COMODO ECC Domain Validation Secure Server CA 2\nO = COMODO CA Limited\nL = Salford\nS = Greater Manchester\nC = GB\n<\/pre>\n<p>There are several possible fields that can show up here, and I don&#8217;t believe the order is guaranteed. This format comes from LDAP \/ Active Directory, and is helpfully called &#8220;<a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa366101(v=vs.85).aspx\">Distinguished Names<\/a>&#8220;.<\/p>\n<p>You can parse these in scala like so:<\/p>\n<pre lang=\"scala\">\nval issuer = new LdapName(cert.getIssuerDN.toString)\nval issuerDN = issuer.getAll()\n\nval issuerDNValues =\n  Iterator\n    .continually(\n      () => {\n        issuerDN.nextElement.split(\"=\")\n      }\n    )\n    .takeWhile(_ => issuerDN.hasMoreElements)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>cert.getIssuerDN.getName cert.getIssuerDN You&#8217;ll get values like this: CN = COMODO ECC Domain Validation Secure Server CA 2 O = COMODO CA Limited L = Salford S = Greater Manchester C = GB There are several possible fields that can show up here, and I don&#8217;t believe the order is guaranteed. This format comes from LDAP &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/parsing-issuerdn-subjectdn-ssl-x-509-certificate\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Parsing the issuerDN \/ subjectDN in an SSL (X.509) certificate in Scala&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[480,528],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3537"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3537"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3537\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}