Home | History | Annotate | Download | only in conscrypt

Lines Matching refs:cn

138         String cn = hostnameCache.get(hostname);
139 if (cn != null) {
141 return entries.get(cn);
144 // otherwise, get the matching cn
145 cn = getMatchingCN(hostname);
146 if (cn != null) {
147 hostnameCache.put(hostname, cn);
148 // we have a matching CN, return that entry
149 return entries.get(cn);
152 // if we got here, we don't have a matching CN for this hostname
162 for (String cn : entries.keySet()) {
164 if (cn.length() < bestMatch.length()) {
167 // now verify that the CN matches at all
168 if (isHostnameMatchedBy(hostname, cn)) {
169 bestMatch = cn;
176 * Returns true if {@code hostName} matches the name or pattern {@code cn}.
179 * @param cn certificate host name. May include wildcards like
182 private static boolean isHostnameMatchedBy(String hostName, String cn) {
183 if (hostName == null || hostName.isEmpty() || cn == null || cn.isEmpty()) {
187 cn = cn.toLowerCase(Locale.US);
189 if (!cn.contains("*")) {
190 return hostName.equals(cn);
193 if (cn.startsWith("*.") && hostName.regionMatches(0, cn, 2, cn.length() - 2)) {
197 int asterisk = cn.indexOf('*');
198 int dot = cn.indexOf('.');
201 // the cn
204 if (!hostName.regionMatches(0, cn, 0, asterisk)) {
208 int suffixLength = cn.length() - (asterisk + 1);
214 if (!hostName.regionMatches(suffixStart, cn, asterisk + 1, suffixLength)) {