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 | |
153 if (found_ip6_chars || !found_alpha) { | 152 if (found_ip6_chars || !found_alpha) { |
153 // For now we just do simple localhost IP address support, primarily as | |
154 // it's needed by the test server. TODO(joth): Replace this with full IP | |
155 // address support. See http://crbug.com/62973 | |
156 if (hostname == "127.0.0.1" && | |
157 std::find(cert_names.begin(), cert_names.end(), hostname) | |
158 != cert_names.end()) { | |
wtc
2010/12/01 22:50:05
Nit: Chromium's style guide recommend folding long
joth
2010/12/02 17:12:01
Done.
| |
159 DVLOG(1) << "Allowing localhost IP certificate: " << hostname; | |
160 return true; | |
161 } | |
154 NOTIMPLEMENTED() << hostname; | 162 NOTIMPLEMENTED() << hostname; |
155 return false; | 163 return false; |
156 } | 164 } |
157 | 165 |
158 // |wildcard_domain| is the remainder of |host| after the leading host | 166 // |wildcard_domain| is the remainder of |host| after the leading host |
159 // component is stripped off, but includes the leading dot e.g. | 167 // component is stripped off, but includes the leading dot e.g. |
160 // "www.f.com" -> ".f.com". | 168 // "www.f.com" -> ".f.com". |
161 // If there is no meaningful domain part to |host| (e.g. it is an IP address | 169 // 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. | 170 // 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 | 171 // 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 } | 221 } |
214 DVLOG(1) << "Could not find any match for " << hostname | 222 DVLOG(1) << "Could not find any match for " << hostname |
215 << " (canonicalized as " << reference_name | 223 << " (canonicalized as " << reference_name |
216 << ") in cert names " << JoinString(cert_names, '|'); | 224 << ") in cert names " << JoinString(cert_names, '|'); |
217 return false; | 225 return false; |
218 } | 226 } |
219 | 227 |
220 } // namespace x509_openssl_util | 228 } // namespace x509_openssl_util |
221 | 229 |
222 } // namespace net | 230 } // namespace net |
OLD | NEW |