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

Side by Side Diff: net/base/cert_verify_proc_openssl.cc

Issue 10545166: Support SHA-256 in public key pins for HTTPS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/cert_verify_proc_openssl.h" 5 #include "net/base/cert_verify_proc_openssl.h"
6 6
7 #include <openssl/x509v3.h> 7 #include <openssl/x509v3.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 } 126 }
127 127
128 if (verified_cert) { 128 if (verified_cert) {
129 verify_result->verified_cert = 129 verify_result->verified_cert =
130 X509Certificate::CreateFromHandle(verified_cert, verified_chain); 130 X509Certificate::CreateFromHandle(verified_cert, verified_chain);
131 } 131 }
132 } 132 }
133 133
134 void AppendPublicKeyHashes(X509_STORE_CTX* store_ctx, 134 void AppendPublicKeyHashes(X509_STORE_CTX* store_ctx,
135 std::vector<SHA1Fingerprint>* hashes) { 135 std::vector<Fingerprint>* hashes) {
136 STACK_OF(X509)* chain = X509_STORE_CTX_get_chain(store_ctx); 136 STACK_OF(X509)* chain = X509_STORE_CTX_get_chain(store_ctx);
137 for (int i = 0; i < sk_X509_num(chain); ++i) { 137 for (int i = 0; i < sk_X509_num(chain); ++i) {
138 X509* cert = sk_X509_value(chain, i); 138 X509* cert = sk_X509_value(chain, i);
139 139
140 std::string der_data; 140 std::string der_data;
141 if (!X509Certificate::GetDEREncoded(cert, &der_data)) 141 if (!X509Certificate::GetDEREncoded(cert, &der_data))
142 continue; 142 continue;
143 143
144 base::StringPiece der_bytes(der_data); 144 base::StringPiece der_bytes(der_data);
145 base::StringPiece spki_bytes; 145 base::StringPiece spki_bytes;
146 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki_bytes)) 146 if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki_bytes))
147 continue; 147 continue;
148 148
149 SHA1Fingerprint hash; 149 Fingerprint hash;
150 hash.tag = FINGERPRINT_SHA1;
150 base::SHA1HashBytes(reinterpret_cast<const uint8*>(spki_bytes.data()), 151 base::SHA1HashBytes(reinterpret_cast<const uint8*>(spki_bytes.data()),
151 spki_bytes.size(), hash.data); 152 spki_bytes.size(), hash.data());
152 hashes->push_back(hash); 153 hashes->push_back(hash);
153 } 154 }
154 } 155 }
155 156
156 #if defined(OS_ANDROID) 157 #if defined(OS_ANDROID)
157 // Returns true if we have verification result in |verify_result| from Android 158 // Returns true if we have verification result in |verify_result| from Android
158 // Trust Manager. Otherwise returns false. 159 // Trust Manager. Otherwise returns false.
159 bool VerifyFromAndroidTrustManager(const std::vector<std::string>& cert_bytes, 160 bool VerifyFromAndroidTrustManager(const std::vector<std::string>& cert_bytes,
160 CertVerifyResult* verify_result) { 161 CertVerifyResult* verify_result) {
161 // TODO(joth): Fetch the authentication type from SSL rather than hardcode. 162 // TODO(joth): Fetch the authentication type from SSL rather than hardcode.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // TODO(joth): if the motivations described in 270 // TODO(joth): if the motivations described in
270 // http://src.chromium.org/viewvc/chrome?view=rev&revision=80778 become an 271 // http://src.chromium.org/viewvc/chrome?view=rev&revision=80778 become an
271 // issue on OpenSSL builds, we will need to embed a hardcoded list of well 272 // issue on OpenSSL builds, we will need to embed a hardcoded list of well
272 // known root CAs, as per the _mac and _win versions. 273 // known root CAs, as per the _mac and _win versions.
273 verify_result->is_issued_by_known_root = true; 274 verify_result->is_issued_by_known_root = true;
274 275
275 return OK; 276 return OK;
276 } 277 }
277 278
278 } // namespace net 279 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698