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

Unified Diff: net/ssl/openssl_client_key_store.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/ssl_server_socket_impl.cc ('k') | net/ssl/openssl_ssl_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ssl/openssl_client_key_store.cc
diff --git a/net/ssl/openssl_client_key_store.cc b/net/ssl/openssl_client_key_store.cc
index 295810f29cc183336600c6963206b6bd056603f2..48895e9ed3a62e6aefc32d8803f7429a08fef2d3 100644
--- a/net/ssl/openssl_client_key_store.cc
+++ b/net/ssl/openssl_client_key_store.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/memory/singleton.h"
+#include "net/cert/asn1_util.h"
#include "net/cert/x509_certificate.h"
#include "net/ssl/ssl_private_key.h"
#include "third_party/boringssl/src/include/openssl/evp.h"
@@ -19,6 +20,16 @@ namespace {
// Serializes the SubjectPublicKeyInfo for |cert|.
bool GetCertificateSPKI(const X509Certificate* cert, std::string* spki) {
+#if BUILDFLAG(USE_BYTE_CERTS)
+ base::StringPiece cert_der(
+ reinterpret_cast<const char*>(CRYPTO_BUFFER_data(cert->os_cert_handle())),
+ CRYPTO_BUFFER_len(cert->os_cert_handle()));
+ base::StringPiece spki_tmp;
+ if (!asn1::ExtractSPKIFromDERCert(cert_der, &spki_tmp))
+ return false;
+ spki_tmp.CopyToString(spki);
+ return true;
+#else
bssl::UniquePtr<EVP_PKEY> pkey(X509_get_pubkey(cert->os_cert_handle()));
if (!pkey) {
LOG(ERROR) << "Can't extract private key from certificate!";
@@ -38,6 +49,7 @@ bool GetCertificateSPKI(const X509Certificate* cert, std::string* spki) {
reinterpret_cast<char*>(der) + der_len);
OPENSSL_free(der);
return true;
+#endif
}
} // namespace
« no previous file with comments | « net/socket/ssl_server_socket_impl.cc ('k') | net/ssl/openssl_ssl_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698