OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ssl/openssl_ssl_util.h" | 5 #include "net/ssl/openssl_ssl_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 | 8 |
9 #include <openssl/err.h> | 9 #include <openssl/err.h> |
10 #include <openssl/ssl.h> | 10 #include <openssl/ssl.h> |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return ERR_SSL_VERSION_OR_CIPHER_MISMATCH; | 145 return ERR_SSL_VERSION_OR_CIPHER_MISMATCH; |
146 } | 146 } |
147 return ERR_SSL_PROTOCOL_ERROR; | 147 return ERR_SSL_PROTOCOL_ERROR; |
148 } | 148 } |
149 default: | 149 default: |
150 LOG(WARNING) << "Unmapped error reason: " << ERR_GET_REASON(error_code); | 150 LOG(WARNING) << "Unmapped error reason: " << ERR_GET_REASON(error_code); |
151 return ERR_SSL_PROTOCOL_ERROR; | 151 return ERR_SSL_PROTOCOL_ERROR; |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 base::Value* NetLogOpenSSLErrorCallback(int net_error, | 155 scoped_ptr<base::Value> NetLogOpenSSLErrorCallback( |
156 int ssl_error, | 156 int net_error, |
157 const OpenSSLErrorInfo& error_info, | 157 int ssl_error, |
158 NetLogCaptureMode /* capture_mode */) { | 158 const OpenSSLErrorInfo& error_info, |
159 base::DictionaryValue* dict = new base::DictionaryValue(); | 159 NetLogCaptureMode /* capture_mode */) { |
| 160 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
160 dict->SetInteger("net_error", net_error); | 161 dict->SetInteger("net_error", net_error); |
161 dict->SetInteger("ssl_error", ssl_error); | 162 dict->SetInteger("ssl_error", ssl_error); |
162 if (error_info.error_code != 0) { | 163 if (error_info.error_code != 0) { |
163 dict->SetInteger("error_lib", ERR_GET_LIB(error_info.error_code)); | 164 dict->SetInteger("error_lib", ERR_GET_LIB(error_info.error_code)); |
164 dict->SetInteger("error_reason", ERR_GET_REASON(error_info.error_code)); | 165 dict->SetInteger("error_reason", ERR_GET_REASON(error_info.error_code)); |
165 } | 166 } |
166 if (error_info.file != NULL) | 167 if (error_info.file != NULL) |
167 dict->SetString("file", error_info.file); | 168 dict->SetString("file", error_info.file); |
168 if (error_info.line != 0) | 169 if (error_info.line != 0) |
169 dict->SetInteger("line", error_info.line); | 170 dict->SetInteger("line", error_info.line); |
170 return dict; | 171 return dict.Pass(); |
171 } | 172 } |
172 | 173 |
173 } // namespace | 174 } // namespace |
174 | 175 |
175 void OpenSSLPutNetError(const tracked_objects::Location& location, int err) { | 176 void OpenSSLPutNetError(const tracked_objects::Location& location, int err) { |
176 // Net error codes are negative. Encode them as positive numbers. | 177 // Net error codes are negative. Encode them as positive numbers. |
177 err = -err; | 178 err = -err; |
178 if (err < 0 || err > 0xfff) { | 179 if (err < 0 || err > 0xfff) { |
179 // OpenSSL reserves 12 bits for the reason code. | 180 // OpenSSL reserves 12 bits for the reason code. |
180 NOTREACHED(); | 181 NOTREACHED(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // TODO(joth): Implement full mapping. | 230 // TODO(joth): Implement full mapping. |
230 LOG(WARNING) << "Unknown OpenSSL error " << err; | 231 LOG(WARNING) << "Unknown OpenSSL error " << err; |
231 return ERR_SSL_PROTOCOL_ERROR; | 232 return ERR_SSL_PROTOCOL_ERROR; |
232 } | 233 } |
233 } | 234 } |
234 | 235 |
235 NetLog::ParametersCallback CreateNetLogOpenSSLErrorCallback( | 236 NetLog::ParametersCallback CreateNetLogOpenSSLErrorCallback( |
236 int net_error, | 237 int net_error, |
237 int ssl_error, | 238 int ssl_error, |
238 const OpenSSLErrorInfo& error_info) { | 239 const OpenSSLErrorInfo& error_info) { |
239 return base::Bind(&NetLogOpenSSLErrorCallback, | 240 return base::Bind(NetLogOpenSSLErrorCallback, net_error, ssl_error, |
240 net_error, ssl_error, error_info); | 241 error_info); |
241 } | 242 } |
242 | 243 |
243 } // namespace net | 244 } // namespace net |
OLD | NEW |