Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Side by Side Diff: net/ssl/openssl_ssl_util.cc

Issue 2958563002: Revert "Disable the buggy RSA parser by default." (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crypto/openssl_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 case SSL_ERROR_WANT_READ: 166 case SSL_ERROR_WANT_READ:
167 case SSL_ERROR_WANT_WRITE: 167 case SSL_ERROR_WANT_WRITE:
168 return ERR_IO_PENDING; 168 return ERR_IO_PENDING;
169 case SSL_ERROR_SYSCALL: 169 case SSL_ERROR_SYSCALL:
170 LOG(ERROR) << "OpenSSL SYSCALL error, earliest error code in " 170 LOG(ERROR) << "OpenSSL SYSCALL error, earliest error code in "
171 "error queue: " << ERR_peek_error() << ", errno: " 171 "error queue: " << ERR_peek_error() << ", errno: "
172 << errno; 172 << errno;
173 return ERR_FAILED; 173 return ERR_FAILED;
174 case SSL_ERROR_SSL: 174 case SSL_ERROR_SSL:
175 // Walk down the error stack to find an SSL or net error. 175 // Walk down the error stack to find an SSL or net error.
176 while (true) { 176 uint32_t error_code;
177 OpenSSLErrorInfo error_info; 177 const char* file;
178 error_info.error_code = 178 int line;
179 ERR_get_error_line(&error_info.file, &error_info.line); 179 do {
180 if (error_info.error_code == 0) { 180 error_code = ERR_get_error_line(&file, &line);
181 // Map errors to ERR_SSL_PROTOCOL_ERROR by default, reporting the most 181 if (ERR_GET_LIB(error_code) == ERR_LIB_SSL) {
182 // recent error in |*out_error_info|. 182 out_error_info->error_code = error_code;
183 return ERR_SSL_PROTOCOL_ERROR; 183 out_error_info->file = file;
184 } 184 out_error_info->line = line;
185 185 return MapOpenSSLErrorSSL(error_code);
186 *out_error_info = error_info; 186 } else if (ERR_GET_LIB(error_code) == OpenSSLNetErrorLib()) {
187 if (ERR_GET_LIB(error_info.error_code) == ERR_LIB_SSL) { 187 out_error_info->error_code = error_code;
188 return MapOpenSSLErrorSSL(error_info.error_code); 188 out_error_info->file = file;
189 } 189 out_error_info->line = line;
190 if (ERR_GET_LIB(error_info.error_code) == OpenSSLNetErrorLib()) {
191 // Net error codes are negative but encoded in OpenSSL as positive 190 // Net error codes are negative but encoded in OpenSSL as positive
192 // numbers. 191 // numbers.
193 return -ERR_GET_REASON(error_info.error_code); 192 return -ERR_GET_REASON(error_code);
194 } 193 }
195 } 194 } while (error_code != 0);
195 return ERR_FAILED;
196 default: 196 default:
197 // TODO(joth): Implement full mapping. 197 // TODO(joth): Implement full mapping.
198 LOG(WARNING) << "Unknown OpenSSL error " << err; 198 LOG(WARNING) << "Unknown OpenSSL error " << err;
199 return ERR_SSL_PROTOCOL_ERROR; 199 return ERR_SSL_PROTOCOL_ERROR;
200 } 200 }
201 } 201 }
202 202
203 NetLogParametersCallback CreateNetLogOpenSSLErrorCallback( 203 NetLogParametersCallback CreateNetLogOpenSSLErrorCallback(
204 int net_error, 204 int net_error,
205 int ssl_error, 205 int ssl_error,
(...skipping 12 matching lines...) Expand all
218 return SSL_CONNECTION_VERSION_TLS1_2; 218 return SSL_CONNECTION_VERSION_TLS1_2;
219 case TLS1_3_VERSION: 219 case TLS1_3_VERSION:
220 return SSL_CONNECTION_VERSION_TLS1_3; 220 return SSL_CONNECTION_VERSION_TLS1_3;
221 default: 221 default:
222 NOTREACHED(); 222 NOTREACHED();
223 return SSL_CONNECTION_VERSION_UNKNOWN; 223 return SSL_CONNECTION_VERSION_UNKNOWN;
224 } 224 }
225 } 225 }
226 226
227 } // namespace net 227 } // namespace net
OLDNEW
« no previous file with comments | « crypto/openssl_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698