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

Side by Side Diff: chrome/common/net/x509_certificate_model_nss.cc

Issue 376753002: Fix webui cert viewer showing wrong cert chain on NSS and no chain on OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 5 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 "chrome/common/net/x509_certificate_model.h" 5 #include "chrome/common/net/x509_certificate_model.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <cms.h> 8 #include <cms.h>
9 #include <hasht.h> 9 #include <hasht.h>
10 #include <keyhi.h> // SECKEY_DestroyPrivateKey 10 #include <keyhi.h> // SECKEY_DestroyPrivateKey
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 217
218 string HashCertSHA256(X509Certificate::OSCertHandle cert_handle) { 218 string HashCertSHA256(X509Certificate::OSCertHandle cert_handle) {
219 return HashCert(cert_handle, HASH_AlgSHA256, SHA256_LENGTH); 219 return HashCert(cert_handle, HASH_AlgSHA256, SHA256_LENGTH);
220 } 220 }
221 221
222 string HashCertSHA1(X509Certificate::OSCertHandle cert_handle) { 222 string HashCertSHA1(X509Certificate::OSCertHandle cert_handle) {
223 return HashCert(cert_handle, HASH_AlgSHA1, SHA1_LENGTH); 223 return HashCert(cert_handle, HASH_AlgSHA1, SHA1_LENGTH);
224 } 224 }
225 225
226 void GetCertChainFromCert(X509Certificate::OSCertHandle cert_handle,
227 X509Certificate::OSCertHandles* cert_handles) {
228 CERTCertList* cert_list =
229 CERT_GetCertChainFromCert(cert_handle, PR_Now(), certUsageSSLServer);
230 CERTCertListNode* node;
231 for (node = CERT_LIST_HEAD(cert_list);
232 !CERT_LIST_END(node, cert_list);
233 node = CERT_LIST_NEXT(node)) {
234 cert_handles->push_back(CERT_DupCertificate(node->cert));
235 }
236 CERT_DestroyCertList(cert_list);
237 }
238
239 void DestroyCertChain(X509Certificate::OSCertHandles* cert_handles) {
240 for (X509Certificate::OSCertHandles::iterator i(cert_handles->begin());
241 i != cert_handles->end(); ++i)
242 CERT_DestroyCertificate(*i);
243 cert_handles->clear();
244 }
245
246 string GetCMSString(const X509Certificate::OSCertHandles& cert_chain, 226 string GetCMSString(const X509Certificate::OSCertHandles& cert_chain,
247 size_t start, size_t end) { 227 size_t start, size_t end) {
248 crypto::ScopedPLArenaPool arena(PORT_NewArena(1024)); 228 crypto::ScopedPLArenaPool arena(PORT_NewArena(1024));
249 DCHECK(arena.get()); 229 DCHECK(arena.get());
250 230
251 ScopedNSSCMSMessage message(NSS_CMSMessage_Create(arena.get())); 231 ScopedNSSCMSMessage message(NSS_CMSMessage_Create(arena.get()));
252 DCHECK(message.get()); 232 DCHECK(message.get());
253 233
254 // First, create SignedData with the certificate only (no chain). 234 // First, create SignedData with the certificate only (no chain).
255 ScopedNSSCMSSignedData signed_data(NSS_CMSSignedData_CreateCertsOnly( 235 ScopedNSSCMSSignedData signed_data(NSS_CMSSignedData_CreateCertsOnly(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 string ProcessSubjectPublicKeyInfo(X509Certificate::OSCertHandle cert_handle) { 293 string ProcessSubjectPublicKeyInfo(X509Certificate::OSCertHandle cert_handle) {
314 return psm::ProcessSubjectPublicKeyInfo(&cert_handle->subjectPublicKeyInfo); 294 return psm::ProcessSubjectPublicKeyInfo(&cert_handle->subjectPublicKeyInfo);
315 } 295 }
316 296
317 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { 297 string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) {
318 return ProcessRawBits(cert_handle->signatureWrap.signature.data, 298 return ProcessRawBits(cert_handle->signatureWrap.signature.data,
319 cert_handle->signatureWrap.signature.len); 299 cert_handle->signatureWrap.signature.len);
320 } 300 }
321 301
322 } // namespace x509_certificate_model 302 } // namespace x509_certificate_model
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698