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

Side by Side Diff: net/cert/cert_database_win.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cert/cert_database.h" 5 #include "net/cert/cert_database.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <wincrypt.h> 8 #include <wincrypt.h>
9 #pragma comment(lib, "crypt32.lib") 9 #pragma comment(lib, "crypt32.lib")
10 10
11 #include "base/observer_list_threadsafe.h" 11 #include "base/observer_list_threadsafe.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/cert/x509_certificate.h" 13 #include "net/cert/x509_certificate.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 CertDatabase::CertDatabase() 17 CertDatabase::CertDatabase()
18 : observer_list_(new ObserverListThreadSafe<Observer>) { 18 : observer_list_(new ObserverListThreadSafe<Observer>) {
19 } 19 }
20 20
21 CertDatabase::~CertDatabase() {} 21 CertDatabase::~CertDatabase() {
22 }
22 23
23 int CertDatabase::CheckUserCert(X509Certificate* cert) { 24 int CertDatabase::CheckUserCert(X509Certificate* cert) {
24 if (!cert) 25 if (!cert)
25 return ERR_CERT_INVALID; 26 return ERR_CERT_INVALID;
26 if (cert->HasExpired()) 27 if (cert->HasExpired())
27 return ERR_CERT_DATE_INVALID; 28 return ERR_CERT_DATE_INVALID;
28 29
29 // TODO(rsleevi): Should CRYPT_FIND_SILENT_KEYSET_FLAG be specified? A UI 30 // TODO(rsleevi): Should CRYPT_FIND_SILENT_KEYSET_FLAG be specified? A UI
30 // may be shown here / this call may block. 31 // may be shown here / this call may block.
31 if (!CryptFindCertificateKeyProvInfo(cert->os_cert_handle(), 0, NULL)) 32 if (!CryptFindCertificateKeyProvInfo(cert->os_cert_handle(), 0, NULL))
32 return ERR_NO_PRIVATE_KEY_FOR_CERT; 33 return ERR_NO_PRIVATE_KEY_FOR_CERT;
33 34
34 return OK; 35 return OK;
35 } 36 }
36 37
37 int CertDatabase::AddUserCert(X509Certificate* cert) { 38 int CertDatabase::AddUserCert(X509Certificate* cert) {
38 // TODO(rsleevi): Would it be more appropriate to have the CertDatabase take 39 // TODO(rsleevi): Would it be more appropriate to have the CertDatabase take
39 // construction parameters (Keychain filepath on Mac OS X, PKCS #11 slot on 40 // construction parameters (Keychain filepath on Mac OS X, PKCS #11 slot on
40 // NSS, and Store Type / Path) here? For now, certs will be stashed into the 41 // NSS, and Store Type / Path) here? For now, certs will be stashed into the
41 // user's personal store, which will not automatically mark them as trusted, 42 // user's personal store, which will not automatically mark them as trusted,
42 // but will allow them to be used for client auth. 43 // but will allow them to be used for client auth.
43 HCERTSTORE cert_db = CertOpenSystemStore(NULL, L"MY"); 44 HCERTSTORE cert_db = CertOpenSystemStore(NULL, L"MY");
44 if (!cert_db) 45 if (!cert_db)
45 return ERR_ADD_USER_CERT_FAILED; 46 return ERR_ADD_USER_CERT_FAILED;
46 47
47 BOOL added = CertAddCertificateContextToStore(cert_db, 48 BOOL added = CertAddCertificateContextToStore(
48 cert->os_cert_handle(), 49 cert_db, cert->os_cert_handle(), CERT_STORE_ADD_USE_EXISTING, NULL);
49 CERT_STORE_ADD_USE_EXISTING,
50 NULL);
51 50
52 CertCloseStore(cert_db, 0); 51 CertCloseStore(cert_db, 0);
53 52
54 if (!added) 53 if (!added)
55 return ERR_ADD_USER_CERT_FAILED; 54 return ERR_ADD_USER_CERT_FAILED;
56 55
57 NotifyObserversOfCertAdded(cert); 56 NotifyObserversOfCertAdded(cert);
58 return OK; 57 return OK;
59 } 58 }
60 59
61 } // namespace net 60 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698