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

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

Issue 4568002: Remember if a user declines to provide a server with a client certificate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and wtc feedback Created 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_BASE_SSL_CLIENT_AUTH_CACHE_H_ 5 #ifndef NET_BASE_SSL_CLIENT_AUTH_CACHE_H_
6 #define NET_BASE_SSL_CLIENT_AUTH_CACHE_H_ 6 #define NET_BASE_SSL_CLIENT_AUTH_CACHE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <map> 10 #include <map>
11 11
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 #include "net/base/x509_certificate.h"
14 13
15 namespace net { 14 namespace net {
16 15
16 class X509Certificate;
17
17 // The SSLClientAuthCache class is a simple cache structure to store SSL 18 // The SSLClientAuthCache class is a simple cache structure to store SSL
18 // client certificates. Provides lookup, insertion, and deletion of entries. 19 // client certificates. Provides lookup, insertion, and deletion of entries.
19 // The parameter for doing lookups, insertions, and deletions is the server's 20 // The parameter for doing lookups, insertions, and deletions is the server's
20 // host and port. 21 // host and port.
21 // 22 //
22 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common 23 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common
23 // code to a template class. 24 // code to a template class.
24 class SSLClientAuthCache { 25 class SSLClientAuthCache {
25 public: 26 public:
26 SSLClientAuthCache(); 27 SSLClientAuthCache();
27 ~SSLClientAuthCache(); 28 ~SSLClientAuthCache();
28 29
29 // Check if we have a client certificate for SSL server at |server|. 30 // Checks for a client certificate preference for SSL server at |server|.
30 // Returns the client certificate (if found) or NULL (if not found). 31 // Returns true if a preference is found, and sets |*certificate| to the
31 X509Certificate* Lookup(const std::string& server); 32 // desired client certificate. The desired certificate may be NULL, which
33 // indicates a preference to not send any certificate to |server|.
34 // If a certificate preference is not found, returns false.
35 bool Lookup(const std::string& server,
36 scoped_refptr<X509Certificate>* certificate);
32 37
33 // Add a client certificate for |server| to the cache. If there is already 38 // Add a client certificate for |server| to the cache. If there is already
34 // a client certificate for |server|, it will be overwritten. Both parameters 39 // a client certificate for |server|, it will be overwritten. A NULL
35 // are IN only. 40 // |client_cert| indicates a preference that no client certificate should
41 // be sent to |server|.
36 void Add(const std::string& server, X509Certificate* client_cert); 42 void Add(const std::string& server, X509Certificate* client_cert);
37 43
38 // Remove the client certificate for |server| from the cache, if one exists. 44 // Remove the client certificate for |server| from the cache, if one exists.
39 void Remove(const std::string& server); 45 void Remove(const std::string& server);
40 46
41 private: 47 private:
42 typedef std::string AuthCacheKey; 48 typedef std::string AuthCacheKey;
43 typedef scoped_refptr<X509Certificate> AuthCacheValue; 49 typedef scoped_refptr<X509Certificate> AuthCacheValue;
44 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; 50 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap;
45 51
46 // internal representation of cache, an STL map. 52 // internal representation of cache, an STL map.
47 AuthCacheMap cache_; 53 AuthCacheMap cache_;
48 }; 54 };
49 55
50 } // namespace net 56 } // namespace net
51 57
52 #endif // NET_BASE_SSL_CLIENT_AUTH_CACHE_H_ 58 #endif // NET_BASE_SSL_CLIENT_AUTH_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/ssl_client_auth_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698