OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/cert_verify_proc_android.h" | 5 #include "net/cert/cert_verify_proc_android.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 HashValue sha256(HASH_VALUE_SHA256); | 85 HashValue sha256(HASH_VALUE_SHA256); |
86 crypto::SHA256HashString(spki_bytes, sha256.data(), crypto::kSHA256Length); | 86 crypto::SHA256HashString(spki_bytes, sha256.data(), crypto::kSHA256Length); |
87 verify_result->public_key_hashes.push_back(sha256); | 87 verify_result->public_key_hashes.push_back(sha256); |
88 } | 88 } |
89 | 89 |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 bool GetChainDEREncodedBytes(X509Certificate* cert, | 93 bool GetChainDEREncodedBytes(X509Certificate* cert, |
94 std::vector<std::string>* chain_bytes) { | 94 std::vector<std::string>* chain_bytes) { |
95 X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle(); | 95 X509Certificate::OSCertHandles cert_handles; |
96 X509Certificate::OSCertHandles cert_handles = | 96 cert->GetCertificateChain(&cert_handles); |
97 cert->GetIntermediateCertificates(); | |
98 | |
99 // Make sure the peer's own cert is the first in the chain, if it's not | |
100 // already there. | |
101 if (cert_handles.empty() || cert_handles[0] != cert_handle) | |
102 cert_handles.insert(cert_handles.begin(), cert_handle); | |
103 | 97 |
104 chain_bytes->reserve(cert_handles.size()); | 98 chain_bytes->reserve(cert_handles.size()); |
105 for (X509Certificate::OSCertHandles::const_iterator it = | 99 for (X509Certificate::OSCertHandles::const_iterator it = |
106 cert_handles.begin(); it != cert_handles.end(); ++it) { | 100 cert_handles.begin(); it != cert_handles.end(); ++it) { |
107 std::string cert_bytes; | 101 std::string cert_bytes; |
108 if(!X509Certificate::GetDEREncoded(*it, &cert_bytes)) | 102 if(!X509Certificate::GetDEREncoded(*it, &cert_bytes)) |
109 return false; | 103 return false; |
110 chain_bytes->push_back(cert_bytes); | 104 chain_bytes->push_back(cert_bytes); |
111 } | 105 } |
112 return true; | 106 return true; |
(...skipping 28 matching lines...) Expand all Loading... |
141 NOTREACHED(); | 135 NOTREACHED(); |
142 return ERR_FAILED; | 136 return ERR_FAILED; |
143 } | 137 } |
144 if (IsCertStatusError(verify_result->cert_status)) | 138 if (IsCertStatusError(verify_result->cert_status)) |
145 return MapCertStatusToNetError(verify_result->cert_status); | 139 return MapCertStatusToNetError(verify_result->cert_status); |
146 | 140 |
147 return OK; | 141 return OK; |
148 } | 142 } |
149 | 143 |
150 } // namespace net | 144 } // namespace net |
OLD | NEW |