OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/x509_openssl_util.h" | 5 #include "net/base/x509_openssl_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 } else if (c == '-') { | 142 } else if (c == '-') { |
143 found_hyphen = true; | 143 found_hyphen = true; |
144 } else if (!IsAsciiDigit(c)) { | 144 } else if (!IsAsciiDigit(c)) { |
145 LOG(WARNING) << "Invalid char " << c << " in hostname " << hostname; | 145 LOG(WARNING) << "Invalid char " << c << " in hostname " << hostname; |
146 return false; | 146 return false; |
147 } | 147 } |
148 reference_name.push_back(c); | 148 reference_name.push_back(c); |
149 } | 149 } |
150 DCHECK(!reference_name.empty()); | 150 DCHECK(!reference_name.empty()); |
151 | 151 |
152 // TODO(joth): Add IP address support. See http://crbug.com/62973 | 152 // TODO(joth): Add full IP address support. See http://crbug.com/62973 |
153 if (found_ip6_chars || !found_alpha) { | 153 if (found_ip6_chars || !found_alpha) { |
154 // Special case localhost connection, to support test server based tests. | |
155 if (hostname == "127.0.0.1" && | |
156 std::find(cert_names.begin(), cert_names.end(), hostname) | |
157 != cert_names.end()) { | |
158 DVLOG(1) << "Allowing localhost IP certificate: " << hostname; | |
bulach
2010/12/01 18:01:33
similar to my comments at http://codereview.chromi
joth
2010/12/02 17:12:01
I rolled this comment into the TODO above to suppo
| |
159 return true; | |
160 } | |
154 NOTIMPLEMENTED() << hostname; | 161 NOTIMPLEMENTED() << hostname; |
155 return false; | 162 return false; |
156 } | 163 } |
157 | 164 |
158 // |wildcard_domain| is the remainder of |host| after the leading host | 165 // |wildcard_domain| is the remainder of |host| after the leading host |
159 // component is stripped off, but includes the leading dot e.g. | 166 // component is stripped off, but includes the leading dot e.g. |
160 // "www.f.com" -> ".f.com". | 167 // "www.f.com" -> ".f.com". |
161 // If there is no meaningful domain part to |host| (e.g. it is an IP address | 168 // If there is no meaningful domain part to |host| (e.g. it is an IP address |
162 // or contains no dots) then |wildcard_domain| will be empty. | 169 // or contains no dots) then |wildcard_domain| will be empty. |
163 // We required at least 3 components (i.e. 2 dots) as a basic protection | 170 // We required at least 3 components (i.e. 2 dots) as a basic protection |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 } | 220 } |
214 DVLOG(1) << "Could not find any match for " << hostname | 221 DVLOG(1) << "Could not find any match for " << hostname |
215 << " (canonicalized as " << reference_name | 222 << " (canonicalized as " << reference_name |
216 << ") in cert names " << JoinString(cert_names, '|'); | 223 << ") in cert names " << JoinString(cert_names, '|'); |
217 return false; | 224 return false; |
218 } | 225 } |
219 | 226 |
220 } // namespace x509_openssl_util | 227 } // namespace x509_openssl_util |
221 | 228 |
222 } // namespace net | 229 } // namespace net |
OLD | NEW |