OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/socket/ssl_host_info.h" | 5 #include "net/socket/ssl_host_info.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "net/base/dns_util.h" | 10 #include "net/base/dns_util.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 return false; | 87 return false; |
88 } | 88 } |
89 | 89 |
90 for (int i = 0; i < num_der_certs; i++) { | 90 for (int i = 0; i < num_der_certs; i++) { |
91 std::string der_cert; | 91 std::string der_cert; |
92 if (!p.ReadString(&iter, &der_cert)) | 92 if (!p.ReadString(&iter, &der_cert)) |
93 return false; | 93 return false; |
94 state->certs.push_back(der_cert); | 94 state->certs.push_back(der_cert); |
95 } | 95 } |
96 | 96 |
| 97 // Ignore obsolete members of the State structure. |
97 std::string throwaway_string; | 98 std::string throwaway_string; |
98 bool throwaway_bool; | 99 bool throwaway_bool; |
| 100 // This was state->server_hello. |
99 if (!p.ReadString(&iter, &throwaway_string)) | 101 if (!p.ReadString(&iter, &throwaway_string)) |
100 return false; | 102 return false; |
101 | 103 |
| 104 // This was state->npn_valid. |
102 if (!p.ReadBool(&iter, &throwaway_bool)) | 105 if (!p.ReadBool(&iter, &throwaway_bool)) |
103 return false; | 106 return false; |
104 | 107 |
105 if (throwaway_bool) { | 108 if (throwaway_bool) { |
106 int throwaway_int; | 109 int throwaway_int; |
| 110 // These were state->npn_status and state->npn_protocol. |
107 if (!p.ReadInt(&iter, &throwaway_int) || | 111 if (!p.ReadInt(&iter, &throwaway_int) || |
108 !p.ReadString(&iter, &throwaway_string)) { | 112 !p.ReadString(&iter, &throwaway_string)) { |
109 return false; | 113 return false; |
110 } | 114 } |
111 } | 115 } |
112 | 116 |
113 if (!state->certs.empty()) { | 117 if (!state->certs.empty()) { |
114 std::vector<base::StringPiece> der_certs(state->certs.size()); | 118 std::vector<base::StringPiece> der_certs(state->certs.size()); |
115 for (size_t i = 0; i < state->certs.size(); i++) | 119 for (size_t i = 0; i < state->certs.size(); i++) |
116 der_certs[i] = state->certs[i]; | 120 der_certs[i] = state->certs[i]; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 158 |
155 if (!p.WriteInt(state_.certs.size())) | 159 if (!p.WriteInt(state_.certs.size())) |
156 return ""; | 160 return ""; |
157 | 161 |
158 for (std::vector<std::string>::const_iterator | 162 for (std::vector<std::string>::const_iterator |
159 i = state_.certs.begin(); i != state_.certs.end(); i++) { | 163 i = state_.certs.begin(); i != state_.certs.end(); i++) { |
160 if (!p.WriteString(*i)) | 164 if (!p.WriteString(*i)) |
161 return ""; | 165 return ""; |
162 } | 166 } |
163 | 167 |
| 168 // Write dummy values for obsolete members of the State structure: |
| 169 // state->server_hello and state->npn_valid. |
164 if (!p.WriteString("") || | 170 if (!p.WriteString("") || |
165 !p.WriteBool(false)) { | 171 !p.WriteBool(false)) { |
166 return ""; | 172 return ""; |
167 } | 173 } |
168 | 174 |
169 return std::string(reinterpret_cast<const char *>(p.data()), p.size()); | 175 return std::string(reinterpret_cast<const char *>(p.data()), p.size()); |
170 } | 176 } |
171 | 177 |
172 const CertVerifyResult& SSLHostInfo::cert_verify_result() const { | 178 const CertVerifyResult& SSLHostInfo::cert_verify_result() const { |
173 return cert_verify_result_; | 179 return cert_verify_result_; |
(...skipping 27 matching lines...) Expand all Loading... |
201 if (cert_verification_callback_) { | 207 if (cert_verification_callback_) { |
202 CompletionCallback* callback = cert_verification_callback_; | 208 CompletionCallback* callback = cert_verification_callback_; |
203 cert_verification_callback_ = NULL; | 209 cert_verification_callback_ = NULL; |
204 callback->Run(rv); | 210 callback->Run(rv); |
205 } | 211 } |
206 } | 212 } |
207 | 213 |
208 SSLHostInfoFactory::~SSLHostInfoFactory() {} | 214 SSLHostInfoFactory::~SSLHostInfoFactory() {} |
209 | 215 |
210 } // namespace net | 216 } // namespace net |
OLD | NEW |