### Question:
DefaultHostnameVerifier implements HttpClientHostnameVerifier { static String extractCN(final String subjectPrincipal) throws SSLException { if (subjectPrincipal == null) { return null; } final List<NameValuePair> attributes = DistinguishedNameParser.INSTANCE.parse(subjectPrincipal); for (final NameValuePair attribute: attributes) { if (TextUtils.isBlank(attribute.getName()) || attribute.getValue() == null) { throw new SSLException(subjectPrincipal + " is not a valid X500 distinguished name"); } if (attribute.getName().equalsIgnoreCase("cn")) { return attribute.getValue(); } } return null; } DefaultHostnameVerifier(final PublicSuffixMatcher publicSuffixMatcher);  DefaultHostnameVerifier(); @Override boolean verify(final String host, final SSLSession session); @Override void verify(
            final String host, final X509Certificate cert);  }### Answer:
@Test public void testExtractCN() throws Exception { Assert.assertEquals("blah", DefaultHostnameVerifier.extractCN("cn=blah, ou=blah, o=blah")); Assert.assertEquals("blah", DefaultHostnameVerifier.extractCN("cn=blah, cn=yada, cn=booh")); Assert.assertEquals("blah", DefaultHostnameVerifier.extractCN("c = pampa , cn = blah , ou = blah , o = blah")); Assert.assertEquals("blah", DefaultHostnameVerifier.extractCN("cn=\"blah\", ou=blah, o=blah")); Assert.assertEquals("blah blah", DefaultHostnameVerifier.extractCN("cn=\"blah blah\", ou=blah, o=blah")); Assert.assertEquals("blah, blah", DefaultHostnameVerifier.extractCN("cn=\"blah, blah\", ou=blah, o=blah")); Assert.assertEquals("blah, blah", DefaultHostnameVerifier.extractCN("cn=blah\\, blah, ou=blah, o=blah")); Assert.assertEquals("blah", DefaultHostnameVerifier.extractCN("c = cn=uuh, cn=blah, ou=blah, o=blah")); try { DefaultHostnameVerifier.extractCN("blah,blah"); Assert.fail("SSLException expected"); } catch (final SSLException expected) { } try { DefaultHostnameVerifier.extractCN("cn,o=blah"); Assert.fail("SSLException expected"); } catch (final SSLException expected) { } }