OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/tools/transport_security_state_generator/input_file_parsers.h" | 5 #include "net/tools/transport_security_state_generator/input_file_parsers.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 enum class CertificateParserState { | 160 enum class CertificateParserState { |
161 PRE_NAME, | 161 PRE_NAME, |
162 POST_NAME, | 162 POST_NAME, |
163 IN_CERTIFICATE, | 163 IN_CERTIFICATE, |
164 IN_PUBLIC_KEY | 164 IN_PUBLIC_KEY |
165 }; | 165 }; |
166 | 166 |
167 } // namespace | 167 } // namespace |
168 | 168 |
169 bool ParseCertificatesFile(base::StringPiece certs_input, Pinsets* pinsets) { | 169 bool ParseCertificatesFile(base::StringPiece certs_input, Pinsets* pinsets) { |
| 170 if (certs_input.find("\r\n") != base::StringPiece::npos) { |
| 171 LOG(ERROR) << "CRLF line-endings found in the pins file. All files must " |
| 172 "use LF (unix style) line-endings."; |
| 173 return false; |
| 174 } |
| 175 |
170 std::string line; | 176 std::string line; |
171 CertificateParserState current_state = CertificateParserState::PRE_NAME; | 177 CertificateParserState current_state = CertificateParserState::PRE_NAME; |
172 | 178 |
173 const base::CompareCase& compare_mode = base::CompareCase::INSENSITIVE_ASCII; | 179 const base::CompareCase& compare_mode = base::CompareCase::INSENSITIVE_ASCII; |
174 std::string name; | 180 std::string name; |
175 std::string buffer; | 181 std::string buffer; |
176 std::string subject_name; | 182 std::string subject_name; |
177 bssl::UniquePtr<X509> certificate; | 183 bssl::UniquePtr<X509> certificate; |
178 SPKIHash hash; | 184 SPKIHash hash; |
179 | 185 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 | 374 |
369 pinsets->RegisterPinset(std::move(pinset)); | 375 pinsets->RegisterPinset(std::move(pinset)); |
370 } | 376 } |
371 | 377 |
372 return true; | 378 return true; |
373 } | 379 } |
374 | 380 |
375 } // namespace transport_security_state | 381 } // namespace transport_security_state |
376 | 382 |
377 } // namespace net | 383 } // namespace net |
OLD | NEW |