| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/cert_util.h" | 5 #include "net/tools/transport_security_state_generator/cert_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 bssl::UniquePtr<X509> GetX509CertificateFromPEM(base::StringPiece pem_data) { | 84 bssl::UniquePtr<X509> GetX509CertificateFromPEM(base::StringPiece pem_data) { |
| 85 std::string der; | 85 std::string der; |
| 86 if (!ParsePEM(pem_data, "CERTIFICATE", &der)) { | 86 if (!ParsePEM(pem_data, "CERTIFICATE", &der)) { |
| 87 return bssl::UniquePtr<X509>(); | 87 return bssl::UniquePtr<X509>(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 const uint8_t* der_data = reinterpret_cast<const uint8_t*>(der.c_str()); | 90 const uint8_t* der_data = reinterpret_cast<const uint8_t*>(der.c_str()); |
| 91 return bssl::UniquePtr<X509>( | 91 return bssl::UniquePtr<X509>( |
| 92 d2i_X509(NULL, &der_data, base::checked_cast<long>(der.size()))); | 92 d2i_X509(nullptr, &der_data, base::checked_cast<long>(der.size()))); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool ExtractSubjectNameFromCertificate(X509* certificate, std::string* name) { | 95 bool ExtractSubjectNameFromCertificate(X509* certificate, std::string* name) { |
| 96 DCHECK(certificate); | 96 DCHECK(certificate); |
| 97 X509_NAME* subject = X509_get_subject_name(certificate); | 97 X509_NAME* subject = X509_get_subject_name(certificate); |
| 98 if (!subject) { | 98 if (!subject) { |
| 99 return false; | 99 return false; |
| 100 } | 100 } |
| 101 | 101 |
| 102 std::string result; | 102 std::string result; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 std::string der; | 146 std::string der; |
| 147 bool result = ParsePEM(pem_key, "PUBLIC KEY", &der); | 147 bool result = ParsePEM(pem_key, "PUBLIC KEY", &der); |
| 148 if (!result) { | 148 if (!result) { |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 out_hash->CalculateFromBytes(reinterpret_cast<const uint8_t*>(der.data()), | 152 out_hash->CalculateFromBytes(reinterpret_cast<const uint8_t*>(der.data()), |
| 153 der.size()); | 153 der.size()); |
| 154 return true; | 154 return true; |
| 155 } | 155 } |
| OLD | NEW |