| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived | 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived |
| 6 // from AuthCertificateCallback() in | 6 // from AuthCertificateCallback() in |
| 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. | 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. |
| 8 | 8 |
| 9 /* ***** BEGIN LICENSE BLOCK ***** | 9 /* ***** BEGIN LICENSE BLOCK ***** |
| 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| (...skipping 2037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2048 if (!chain_context) { | 2048 if (!chain_context) { |
| 2049 DWORD err = GetLastError(); | 2049 DWORD err = GetLastError(); |
| 2050 if (err != CRYPT_E_NOT_FOUND) | 2050 if (err != CRYPT_E_NOT_FOUND) |
| 2051 DLOG(ERROR) << "CertFindChainInStore failed: " << err; | 2051 DLOG(ERROR) << "CertFindChainInStore failed: " << err; |
| 2052 break; | 2052 break; |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 // Get the leaf certificate. | 2055 // Get the leaf certificate. |
| 2056 PCCERT_CONTEXT cert_context = | 2056 PCCERT_CONTEXT cert_context = |
| 2057 chain_context->rgpChain[0]->rgpElement[0]->pCertContext; | 2057 chain_context->rgpChain[0]->rgpElement[0]->pCertContext; |
| 2058 // Copy the certificate into a NULL store, so that we can close the "MY" | 2058 // Copy it to our own certificate store, so that we can close the "MY" |
| 2059 // store before returning from this function. | 2059 // certificate store before returning from this function. |
| 2060 PCCERT_CONTEXT cert_context2; | 2060 PCCERT_CONTEXT cert_context2; |
| 2061 BOOL ok = CertAddCertificateContextToStore(NULL, cert_context, | 2061 BOOL ok = CertAddCertificateContextToStore(X509Certificate::cert_store(), |
| 2062 cert_context, |
| 2062 CERT_STORE_ADD_USE_EXISTING, | 2063 CERT_STORE_ADD_USE_EXISTING, |
| 2063 &cert_context2); | 2064 &cert_context2); |
| 2064 if (!ok) { | 2065 if (!ok) { |
| 2065 NOTREACHED(); | 2066 NOTREACHED(); |
| 2066 continue; | 2067 continue; |
| 2067 } | 2068 } |
| 2068 | 2069 |
| 2069 // Copy the rest of the chain to our own store as well. Copying the chain | 2070 // Copy the rest of the chain to our own store as well. Copying the chain |
| 2070 // stops gracefully if an error is encountered, with the partial chain | 2071 // stops gracefully if an error is encountered, with the partial chain |
| 2071 // being used as the intermediates, rather than failing to consider the | 2072 // being used as the intermediates, rather than failing to consider the |
| 2072 // client certificate. | 2073 // client certificate. |
| 2073 net::X509Certificate::OSCertHandles intermediates; | 2074 net::X509Certificate::OSCertHandles intermediates; |
| 2074 for (DWORD i = 1; i < chain_context->rgpChain[0]->cElement; i++) { | 2075 for (DWORD i = 1; i < chain_context->rgpChain[0]->cElement; i++) { |
| 2075 PCCERT_CONTEXT intermediate_copy; | 2076 PCCERT_CONTEXT intermediate_copy; |
| 2076 ok = CertAddCertificateContextToStore( | 2077 ok = CertAddCertificateContextToStore(X509Certificate::cert_store(), |
| 2077 NULL, chain_context->rgpChain[0]->rgpElement[i]->pCertContext, | 2078 chain_context->rgpChain[0]->rgpElement[i]->pCertContext, |
| 2078 CERT_STORE_ADD_USE_EXISTING, &intermediate_copy); | 2079 CERT_STORE_ADD_USE_EXISTING, &intermediate_copy); |
| 2079 if (!ok) { | 2080 if (!ok) { |
| 2080 NOTREACHED(); | 2081 NOTREACHED(); |
| 2081 break; | 2082 break; |
| 2082 } | 2083 } |
| 2083 intermediates.push_back(intermediate_copy); | 2084 intermediates.push_back(intermediate_copy); |
| 2084 } | 2085 } |
| 2085 | 2086 |
| 2086 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle( | 2087 scoped_refptr<X509Certificate> cert = X509Certificate::CreateFromHandle( |
| 2087 cert_context2, intermediates); | 2088 cert_context2, intermediates); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2280 valid_thread_id_ = base::PlatformThread::CurrentId(); | 2281 valid_thread_id_ = base::PlatformThread::CurrentId(); |
| 2281 } | 2282 } |
| 2282 | 2283 |
| 2283 bool SSLClientSocketNSS::CalledOnValidThread() const { | 2284 bool SSLClientSocketNSS::CalledOnValidThread() const { |
| 2284 EnsureThreadIdAssigned(); | 2285 EnsureThreadIdAssigned(); |
| 2285 base::AutoLock auto_lock(lock_); | 2286 base::AutoLock auto_lock(lock_); |
| 2286 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2287 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
| 2287 } | 2288 } |
| 2288 | 2289 |
| 2289 } // namespace net | 2290 } // namespace net |
| OLD | NEW |