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

Side by Side Diff: net/ssl/ssl_client_auth_cache.h

Issue 1422573008: Plumbing SSLPrivateKey (//net) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing un-needed forward decl. Created 5 years, 1 month 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
« no previous file with comments | « net/ssl/client_key_store.cc ('k') | net/ssl/ssl_client_auth_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ 5 #ifndef NET_SSL_SSL_CLIENT_AUTH_CACHE_H_
6 #define NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ 6 #define NET_SSL_SSL_CLIENT_AUTH_CACHE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <utility>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "net/base/host_port_pair.h" 14 #include "net/base/host_port_pair.h"
14 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
15 #include "net/cert/cert_database.h" 16 #include "net/cert/cert_database.h"
17 #include "net/ssl/ssl_private_key.h"
16 18
17 namespace net { 19 namespace net {
18 20
19 class X509Certificate; 21 class X509Certificate;
20 22
21 // The SSLClientAuthCache class is a simple cache structure to store SSL 23 // The SSLClientAuthCache class is a simple cache structure to store SSL
22 // client certificates. Provides lookup, insertion, and deletion of entries. 24 // client certificates. Provides lookup, insertion, and deletion of entries.
23 // The parameter for doing lookups, insertions, and deletions is the server's 25 // The parameter for doing lookups, insertions, and deletions is the server's
24 // host and port. 26 // host and port.
25 // 27 //
26 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common 28 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common
27 // code to a template class. 29 // code to a template class.
28 class NET_EXPORT_PRIVATE SSLClientAuthCache : public CertDatabase::Observer { 30 class NET_EXPORT_PRIVATE SSLClientAuthCache : public CertDatabase::Observer {
29 public: 31 public:
30 SSLClientAuthCache(); 32 SSLClientAuthCache();
31 ~SSLClientAuthCache() override; 33 ~SSLClientAuthCache() override;
32 34
33 // Checks for a client certificate preference for SSL server at |server|. 35 // Checks for a client certificate preference for SSL server at |server|.
34 // Returns true if a preference is found, and sets |*certificate| to the 36 // Returns true if a preference is found, and sets |*certificate| to the
35 // desired client certificate. The desired certificate may be NULL, which 37 // desired client certificate. The desired certificate may be NULL, which
36 // indicates a preference to not send any certificate to |server|. 38 // indicates a preference to not send any certificate to |server|.
37 // If a certificate preference is not found, returns false. 39 // If a certificate preference is not found, returns false.
38 bool Lookup(const HostPortPair& server, 40 bool Lookup(const HostPortPair& server,
39 scoped_refptr<X509Certificate>* certificate); 41 scoped_refptr<X509Certificate>* certificate,
42 scoped_refptr<SSLPrivateKey>* private_key);
40 43
41 // Add a client certificate for |server| to the cache. If there is already 44 // Add a client certificate and private key for |server| to the cache. If
42 // a client certificate for |server|, it will be overwritten. A NULL 45 // there is already a client certificate for |server|, it will be
43 // |client_cert| indicates a preference that no client certificate should 46 // overwritten. A NULL |client_cert| indicates a preference that no client
44 // be sent to |server|. 47 // certificate should be sent to |server|.
45 void Add(const HostPortPair& server, X509Certificate* client_cert); 48 void Add(const HostPortPair& server,
49 X509Certificate* client_cert,
50 SSLPrivateKey* private_key);
46 51
47 // Remove the client certificate for |server| from the cache, if one exists. 52 // Remove the client certificate for |server| from the cache, if one exists.
48 void Remove(const HostPortPair& server); 53 void Remove(const HostPortPair& server);
49 54
50 // CertDatabase::Observer methods: 55 // CertDatabase::Observer methods:
51 void OnCertAdded(const X509Certificate* cert) override; 56 void OnCertAdded(const X509Certificate* cert) override;
52 57
53 private: 58 private:
54 typedef HostPortPair AuthCacheKey; 59 typedef HostPortPair AuthCacheKey;
55 typedef scoped_refptr<X509Certificate> AuthCacheValue; 60 typedef std::pair<scoped_refptr<X509Certificate>,
61 scoped_refptr<SSLPrivateKey>> AuthCacheValue;
56 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; 62 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap;
57 63
58 // internal representation of cache, an STL map. 64 // internal representation of cache, an STL map.
59 AuthCacheMap cache_; 65 AuthCacheMap cache_;
60 }; 66 };
61 67
62 } // namespace net 68 } // namespace net
63 69
64 #endif // NET_SSL_SSL_CLIENT_AUTH_CACHE_H_ 70 #endif // NET_SSL_SSL_CLIENT_AUTH_CACHE_H_
OLDNEW
« no previous file with comments | « net/ssl/client_key_store.cc ('k') | net/ssl/ssl_client_auth_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698