Home | History | Annotate | Download | only in ssl
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef NET_SSL_CLIENT_CERT_STORE_IMPL_H_
      6 #define NET_SSL_CLIENT_CERT_STORE_IMPL_H_
      7 
      8 #include "base/basictypes.h"
      9 #include "base/gtest_prod_util.h"
     10 #include "net/base/net_export.h"
     11 #include "net/ssl/client_cert_store.h"
     12 #include "net/ssl/ssl_cert_request_info.h"
     13 
     14 namespace net {
     15 
     16 class NET_EXPORT ClientCertStoreImpl : public ClientCertStore {
     17  public:
     18   ClientCertStoreImpl() {}
     19   virtual ~ClientCertStoreImpl() {}
     20 
     21   // ClientCertStore:
     22   virtual bool GetClientCerts(const SSLCertRequestInfo& cert_request_info,
     23                               CertificateList* selected_certs) OVERRIDE;
     24 
     25  private:
     26   friend class ClientCertStoreImplTest;
     27 
     28   // A hook for testing. Filters |input_certs| using the logic being used to
     29   // filter the system store when GetClientCerts() is called. Depending on the
     30   // implementation, this might be:
     31   // - Implemented by creating a temporary in-memory store and filtering it
     32   // using the common logic (preferable, currently on Windows).
     33   // - Implemented by creating a list of certificates that otherwise would be
     34   // extracted from the system store and filtering it using the common logic
     35   // (less adequate, currently on NSS and Mac).
     36   bool SelectClientCertsForTesting(const CertificateList& input_certs,
     37                                    const SSLCertRequestInfo& cert_request_info,
     38                                    CertificateList* selected_certs);
     39 
     40 #if defined(OS_MACOSX) && !defined(OS_IOS)
     41   // Testing hook specific to Mac, where the internal logic recognizes preferred
     42   // certificates for particular domains. If the preferred certificate is
     43   // present in the output list (i.e. it doesn't get filtered out), it should
     44   // always come first.
     45   bool SelectClientCertsGivenPreferredForTesting(
     46       const scoped_refptr<X509Certificate>& preferred_cert,
     47       const CertificateList& regular_certs,
     48       const SSLCertRequestInfo& request,
     49       CertificateList* selected_certs);
     50 #endif
     51 
     52   DISALLOW_COPY_AND_ASSIGN(ClientCertStoreImpl);
     53 };
     54 
     55 }  // namespace net
     56 
     57 #endif  // NET_SSL_CLIENT_CERT_STORE_IMPL_H_
     58