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

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

Issue 2786173003: Convert android to use X509CertificateBytes instead of X509CertificateOpenSSL. (Closed)
Patch Set: ssl_server_socket_impl.cc simplifications Created 3 years, 8 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 | « net/ssl/openssl_client_key_store.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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 case TLS1_3_VERSION: 220 case TLS1_3_VERSION:
221 return SSL_CONNECTION_VERSION_TLS1_3; 221 return SSL_CONNECTION_VERSION_TLS1_3;
222 default: 222 default:
223 NOTREACHED(); 223 NOTREACHED();
224 return SSL_CONNECTION_VERSION_UNKNOWN; 224 return SSL_CONNECTION_VERSION_UNKNOWN;
225 } 225 }
226 } 226 }
227 227
228 bssl::UniquePtr<X509> OSCertHandleToOpenSSL( 228 bssl::UniquePtr<X509> OSCertHandleToOpenSSL(
229 X509Certificate::OSCertHandle os_handle) { 229 X509Certificate::OSCertHandle os_handle) {
230 #if defined(USE_OPENSSL_CERTS) 230 #if BUILDFLAG(USE_BYTE_CERTS)
231 return bssl::UniquePtr<X509>(X509_parse_from_buffer(os_handle));
232 #elif defined(USE_OPENSSL_CERTS)
231 return bssl::UniquePtr<X509>(X509Certificate::DupOSCertHandle(os_handle)); 233 return bssl::UniquePtr<X509>(X509Certificate::DupOSCertHandle(os_handle));
232 #else // !defined(USE_OPENSSL_CERTS) 234 #else // !defined(USE_OPENSSL_CERTS) && !BUILDFLAG(USE_BYTE_CERTS)
233 std::string der_encoded; 235 std::string der_encoded;
234 if (!X509Certificate::GetDEREncoded(os_handle, &der_encoded)) 236 if (!X509Certificate::GetDEREncoded(os_handle, &der_encoded))
235 return bssl::UniquePtr<X509>(); 237 return bssl::UniquePtr<X509>();
236 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(der_encoded.data()); 238 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(der_encoded.data());
237 return bssl::UniquePtr<X509>(d2i_X509(NULL, &bytes, der_encoded.size())); 239 return bssl::UniquePtr<X509>(d2i_X509(NULL, &bytes, der_encoded.size()));
238 #endif // defined(USE_OPENSSL_CERTS) 240 #endif // defined(USE_OPENSSL_CERTS) && BUILDFLAG(USE_BYTE_CERTS)
239 } 241 }
240 242
241 bssl::UniquePtr<STACK_OF(X509)> OSCertHandlesToOpenSSL( 243 bssl::UniquePtr<STACK_OF(X509)> OSCertHandlesToOpenSSL(
242 const X509Certificate::OSCertHandles& os_handles) { 244 const X509Certificate::OSCertHandles& os_handles) {
243 bssl::UniquePtr<STACK_OF(X509)> stack(sk_X509_new_null()); 245 bssl::UniquePtr<STACK_OF(X509)> stack(sk_X509_new_null());
244 for (size_t i = 0; i < os_handles.size(); i++) { 246 for (size_t i = 0; i < os_handles.size(); i++) {
245 bssl::UniquePtr<X509> x509 = OSCertHandleToOpenSSL(os_handles[i]); 247 bssl::UniquePtr<X509> x509 = OSCertHandleToOpenSSL(os_handles[i]);
246 if (!x509) 248 if (!x509)
247 return nullptr; 249 return nullptr;
248 sk_X509_push(stack.get(), x509.release()); 250 sk_X509_push(stack.get(), x509.release());
249 } 251 }
250 return stack; 252 return stack;
251 } 253 }
252 254
253 } // namespace net 255 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/openssl_client_key_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698