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

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

Issue 2898573002: Refactor client cert private key handling. (Closed)
Patch Set: removed no longer needed forward declaration Created 3 years, 6 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
« no previous file with comments | « net/ssl/client_cert_identity_mac.cc ('k') | net/ssl/client_cert_identity_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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_SSL_CLIENT_CERT_IDENTITY_TEST_UTIL_H_
6 #define NET_SSL_SSL_CLIENT_CERT_IDENTITY_TEST_UTIL_H_
7
8 #include "net/ssl/client_cert_identity.h"
9
10 namespace base {
11 class FilePath;
12 }
13
14 namespace net {
15
16 // Simple ClientCertIdentity implementation for testing.
17 // Note: this implementation of AcquirePrivateKey will always call the callback
18 // synchronously.
19 class FakeClientCertIdentity : public ClientCertIdentity {
20 public:
21 FakeClientCertIdentity(scoped_refptr<X509Certificate> cert,
22 scoped_refptr<SSLPrivateKey> key);
23 ~FakeClientCertIdentity() override;
24
25 // Creates a FakeClientCertIdentity from a certificate file (DER or PEM) and
26 // private key file (unencrypted pkcs8). Returns nullptr on error.
27 static std::unique_ptr<FakeClientCertIdentity> CreateFromCertAndKeyFiles(
28 const base::FilePath& dir,
29 const std::string& cert_filename,
30 const std::string& key_filename);
31
32 // Duplicates the FakeClientCertIdentity.
33 std::unique_ptr<FakeClientCertIdentity> Copy();
34
35 // Returns the SSLPrivateKey in a more convenient way, for tests.
36 SSLPrivateKey* ssl_private_key() const { return key_.get(); }
37
38 // ClientCertIdentity implementation:
39 void AcquirePrivateKey(
40 const base::Callback<void(scoped_refptr<SSLPrivateKey>)>&
41 private_key_callback) override;
42 #if defined(OS_MACOSX)
43 SecIdentityRef sec_identity_ref() const override;
44 #endif
45
46 private:
47 scoped_refptr<SSLPrivateKey> key_;
48 };
49
50 // Converts a CertificateList to a ClientCertIdentityList of
51 // FakeClientCertIdentity, with null private keys.
52 ClientCertIdentityList FakeClientCertIdentityListFromCertificateList(
53 const CertificateList& certs);
54
55 } // namespace net
56
57 #endif // NET_SSL_SSL_CLIENT_CERT_IDENTITY_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/ssl/client_cert_identity_mac.cc ('k') | net/ssl/client_cert_identity_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698